SHA2
Category: Hashing
Status: Registered and callable in the CyberChef 11.3.0 compatibility inventory.
Input / output: ArrayBuffer → string
Background: https://wikipedia.org/wiki/SHA-2
What it does
The SHA-2 (Secure Hash Algorithm 2) hash functions were designed by the NSA. SHA-2 includes significant changes from its predecessor, SHA-1. The SHA-2 family consists of hash functions with digests (hash values) that are 224, 256, 384 or 512 bits: SHA224, SHA256, SHA384, SHA512.
SHA-512 operates on 64-bit words.
SHA-256 operates on 32-bit words.
SHA-384 is largely identical to SHA-512 but is truncated to 384 bits.
SHA-224 is largely identical to SHA-256 but is truncated to 224 bits.
SHA-512/224 and SHA-512/256 are truncated versions of SHA-512, but the initial values are generated using the method described in Federal Information Processing Standards (FIPS) PUB 180-4.
The message digest algorithm for SHA256 variants consists, by default, of 64 rounds, and for SHA512 variants, it is, by default, 160.
Note
Status here means the operation name is implemented and callable. It does not by itself promise byte-for-byte parity for every upstream option. See Compatibility and current status for the verified scope and known boundaries.
Arguments and options
Arguments are positional. Keep their order when using bake() or
Pipeline.then().
Index |
Name |
UI type |
PyChef default |
Accepted values / format |
|---|---|---|---|---|
|
Size |
|
|
|
|
Rounds |
|
|
A Python integer or floating-point value |
|
Rounds |
|
|
A Python integer or floating-point value |
Working recipe example
from pychef import bake
input_value = b"hello"
args = [256]
result = bake(input_value, [{"op": 'SHA2', "args": args}])
print(result)
Expected representation: 2cf24dba5fb0a30e....
Pipeline example
from pychef import Pipeline
args = [256]
transform = Pipeline().then('SHA2', *args)
result = transform(b"hello")
Dedicated operation module
The registered entry point lives in
pychef.operations.by_operation.sha2. Direct calls
receive the input value and a positional argument tuple:
from pychef.operations.by_operation.sha2 import run
result = run(b"hello", tuple([256]))
- pychef.operations.by_operation.sha2.run(value, args)
Run this operation using its shared internal implementation.
- Parameters:
value (str | bytes)
args (Sequence[Any])
- Return type:
str | bytes