@tevm/voltaire / crypto/SHA256
crypto/SHA256
Variables
BLOCK_SIZE
Defined in: src/crypto/SHA256/constants.js:27 SHA256 block size in bytesconstBLOCK_SIZE:64=64
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
OUTPUT_SIZE
Defined in: src/crypto/SHA256/constants.js:13 SHA256 output size in bytes (256 bits / 8)constOUTPUT_SIZE:32=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SHA256
Defined in: src/crypto/SHA256/SHA256.js:62constSHA256: (input) =>SHA256Hash&object=SHA256Hash
Type Declaration
BLOCK_SIZE
BLOCK_SIZE: number
SHA256 block size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
create()
create: () => object
Incremental hasher for streaming data
Returns
object
Hasher instance
digest()
digest: () => Uint8Array
Returns
Uint8Array
update()
update: (data) =>void
Parameters
data
Uint8Array
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
from()
from: (Hash input with SHA256 (constructor pattern) Auto-detects input type and hashes accordingly:input) =>SHA256Hash
- Uint8Array: hash directly
- string starting with 0x: parse as hex
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto/sha256 for crypto documentationSince
0.0.0Throws
Example
fromHex()
fromHex: (Compute SHA256 hash of hex string (without 0x prefix)hex) =>SHA256Hash=hashHex
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
fromString()
fromString: (Compute SHA256 hash of UTF-8 stringstr) =>SHA256Hash=hashString
Parameters
str
string
Input string
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hash()
hash: (Compute SHA256 hash of input datadata) =>SHA256Hash
Parameters
data
Uint8Array<ArrayBufferLike>
Input data as Uint8Array
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex: (Compute SHA256 hash of hex string (without 0x prefix)hex) =>SHA256Hash
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString: (Compute SHA256 hash of UTF-8 stringstr) =>SHA256Hash
Parameters
str
string
Input string
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
OUTPUT_SIZE
OUTPUT_SIZE: number
SHA256 output size in bytes (256 bits / 8)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
toHex()
toHex: (Convert hash output to hex stringhash) =>string
Parameters
hash
Uint8Array<ArrayBufferLike>
Hash bytes
Returns
string
Hex string with 0x prefix
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Deprecated
Use SHA256Hash instead SHA256 alias maintained for backward compatibilityFunctions
create()
create(): object
Defined in: src/crypto/SHA256/create.js:19
Incremental hasher for streaming data
Returns
object
Hasher instance
digest()
digest: () => Uint8Array
Returns
Uint8Array
update()
update: (data) =>void
Parameters
data
Uint8Array
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
from()
from(Defined in: src/crypto/SHA256/from.js:27 Hash input with SHA256 (constructor pattern) Auto-detects input type and hashes accordingly:input):SHA256Hash
- Uint8Array: hash directly
- string starting with 0x: parse as hex
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto/sha256 for crypto documentationSince
0.0.0Throws
Example
hash()
hash(Defined in: src/crypto/SHA256/hash.js:18 Compute SHA256 hash of input datadata):SHA256Hash
Parameters
data
Uint8Array<ArrayBufferLike>
Input data as Uint8Array
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex(Defined in: src/crypto/SHA256/hashHex.js:18 Compute SHA256 hash of hex string (without 0x prefix)hex):SHA256Hash
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString(Defined in: src/crypto/SHA256/hashString.js:18 Compute SHA256 hash of UTF-8 stringstr):SHA256Hash
Parameters
str
string
Input string
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
toHex()
toHex(Defined in: src/crypto/SHA256/toHex.js:17 Convert hash output to hex stringhash):string
Parameters
hash
Uint8Array<ArrayBufferLike>
Hash bytes
Returns
string
Hex string with 0x prefix

