capstone.utils.crypto
Description: This module provides reusable cryptographic utilities.
compute_sha256(for_file_path)
Compute the SHA-256 hash of a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
for_file_path
|
str
|
Path to the file. |
required |
Returns:
Type | Description |
---|---|
str
|
The SHA-256 hash as a hexadecimal string. |
Source code in capstone/utils/crypto.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
validate_sha256(sha256)
Validates the SHA-256 checksum format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sha256
|
str
|
The SHA-256 checksum to validate. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the checksum is valid, False otherwise. |
Source code in capstone/utils/crypto.py
69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
verify_sha256(for_file_path, expected_hash)
Verify the SHA-256 hash of a file against an expected hash.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
for_file_path
|
str
|
Path to the file. |
required |
expected_hash
|
str
|
The expected SHA-256 hash as a hexadecimal string. |
required |
Returns: True if the computed hash matches the expected hash, False otherwise.
Source code in capstone/utils/crypto.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|