libsodium_crypto_hash (libsodium v3.0.1)

View Source

The default fixed-output hash function, currently SHA-512, producing bytes/0 byte digests.

SHA-2 is vulnerable to length extension attacks; unless SHA-512 is required for interoperability, prefer libsodium_crypto_generichash. For streaming SHA-512, use libsodium_crypto_hash_sha512.

Digest = libsodium_crypto_hash:crypto_hash(<<"hello world">>),
64 = byte_size(Digest),
Digest = libsodium_crypto_hash_sha512:crypto_hash_sha512(<<"hello world">>).

Summary

Types

A crypto_hash_BYTES (64-byte) binary.

Functions

Return crypto_hash_bytes(), in bytes.

Hash In, returning a bytes/0 byte digest.

Return crypto_hash_primitive() as an atom.

Types

out()

-type out() :: <<_:512>>.

A crypto_hash_BYTES (64-byte) binary.

Functions

bytes()

-spec bytes() -> Result when Result :: 64.

Return crypto_hash_bytes(), in bytes.

crypto_hash(In)

-spec crypto_hash(In) -> Result when In :: binary(), Result :: out() | -1.

Hash In, returning a bytes/0 byte digest.

primitive()

-spec primitive() -> Result when Result :: sha512.

Return crypto_hash_primitive() as an atom.