A package that implements the following hashing algorithms (based on RustCrypto
's crates):
- BLAKE2
- BLAKE2s
- MD5
- SHA-1
- SHA-224
- SHA-256
- SHA-384
- SHA-512
- SHA-3
Hashes the given data using the given algorithm.
hash.hash(
string,
string | array | bytes,
) -> bytes
The algorithm to use for hashing. There also exist convenience methods for each algorithm that only take the data to hash.
"blake2"
"blake2s"
"md5"
"sha1"
"sha224"
"sha256"
"sha384"
"sha512"
"sha3"
The data to hash.
Converts a given bytes object to a hexadecimal string.
hash.hex(bytes) -> string
The bytes object to convert.
Hashes the given data using the BLAKE2 algorithm.
hash.blake2(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the BLAKE2s algorithm.
hash.blake2s(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the MD5 algorithm.
hash.md5(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the SHA-1 algorithm.
hash.sha1(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the SHA-224 algorithm.
hash.sha224(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the SHA-256 algorithm.
hash.sha256(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the SHA-384 algorithm.
hash.sha384(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the SHA-512 algorithm.
hash.sha512(string | array | bytes) -> bytes
The data to hash.
Hashes the given data using the SHA-3 algorithm.
hash.sha3(string | array | bytes) -> bytes
The data to hash.
#import "@local/hash:0.1.0": hash, hex, md5, sha256, sha3
#table(
columns: 2,
table.header[*Digest*][*Hash*],
[BLAKE2], hex(hash("blake2", "Hello world!")),
[BLAKE2s], hex(hash("blake2s", "Hello world!")),
[MD5], hex(md5("Hello world!")),
[SHA-1], hex(hash("sha1", "Hello world!")),
[SHA-224], hex(hash("sha224", "Hello world!")),
[SHA-256], hex(sha256("Hello world!")),
[SHA-384], hex(hash("sha384", "Hello world!")),
[SHA-512], hex(hash("sha512", "Hello world!")),
[SHA-3], hex(sha3("Hello world!")),
)