libsodium_crypto_hash_sha3256 (libsodium v3.0.1)
View SourceSHA3-256 (FIPS 202), producing bytes/0 byte digests, either in one shot
or incrementally.
The streaming functions thread an opaque state/0 through init/0,
update/2, and final/1; each call returns a new state and leaves its
argument unchanged. Updates over large inputs yield to other processes
between chunks.
Unlike SHA-2, SHA-3 is not vulnerable to length extension attacks. Use it
when SHA-3 is required for interoperability; otherwise
libsodium_crypto_generichash is faster.
Digest = libsodium_crypto_hash_sha3256:crypto_hash_sha3256(<<"hello world">>),
32 = byte_size(Digest),
State0 = libsodium_crypto_hash_sha3256:init(),
State1 = libsodium_crypto_hash_sha3256:update(State0, <<"hello ">>),
State2 = libsodium_crypto_hash_sha3256:update(State1, <<"world">>),
Digest = libsodium_crypto_hash_sha3256:final(State2).
Summary
Functions
Return crypto_hash_sha3256_bytes(), in bytes.
Hash In, returning a bytes/0 byte digest.
Finish the streaming hash in State, returning a bytes/0 byte digest.
Start a streaming hash, returning its state.
Return crypto_hash_sha3256_statebytes(), in bytes.
Absorb In into State and return the updated state.
Types
-type out() :: <<_:256>>.
A crypto_hash_sha3256_BYTES (32-byte) binary.
-type state() :: libsodium_nif:crypto_hash_sha3256_state().
An opaque native crypto_hash_sha3256_state.
Operations never modify a state: each returns a new one, so earlier states remain valid and can be reused or shared between processes. States cannot be serialized; they exist only within the running VM.
Functions
-spec bytes() -> Result when Result :: 32.
Return crypto_hash_sha3256_bytes(), in bytes.
Hash In, returning a bytes/0 byte digest.
Finish the streaming hash in State, returning a bytes/0 byte digest.
-spec init() -> Result when Result :: state() | -1.
Start a streaming hash, returning its state.
-spec statebytes() -> Result when Result :: 256.
Return crypto_hash_sha3256_statebytes(), in bytes.
Absorb In into State and return the updated state.