crypt. hash Synchronous
Compute a digest of the supplied data using the selected algorithm. Use it to fingerprint file contents or compare whether bytes have changed. A hash does not encrypt data, and a plain digest does not authenticate its sender.
Luau
crypt.hash(data: string, algorithm: string, key: string?) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | Bytes to hash, up to 16 MiB. |
algorithm | string | MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA3-224, SHA3-256, SHA3-384, SHA3-512, or BLAKE2B. Case and common separator variants are normalized. |
key | string? | Optional raw key for BLAKE2B, up to 64 bytes. Other digest algorithms ignore this argument. |
Returns
stringThe digest as lowercase hexadecimal text.
Example
Luau
local first = crypt.hash("draft one", "SHA256")
local second = crypt.hash("draft two", "SHA256")
print(first == crypt.hash("draft one", "SHA256")) -- true
print(first == second) -- false