crypto
luau
local crypto = require("@lute/crypto")WARNING
These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.
Summary
| Entry | Description |
|---|---|
| SecretBox | A sealed message containing the encrypted ciphertext, nonce, and key. |
| digest | Computes a cryptographic hash of message using the given hash algorithm. Returns the hash as a buffer. |
| password.hash | Hashes password using a slow, memory-hard algorithm suitable for password storage. Returns the hash as a buffer. |
| password.verify | Verifies that password matches the stored hash. Returns true if the password is correct. |
| secretbox.keygen | Generates a new random secret key for use with secretbox.seal. |
| secretbox.open | Decrypts box and returns the original plaintext as a buffer. |
| secretbox.seal | Encrypts message with key (or a freshly generated key if omitted). Returns a SecretBox. |
Types
SecretBox
A sealed message containing the encrypted ciphertext, nonce, and key.
luau
type SecretBox = {
read ciphertext: buffer,
read nonce: buffer,
read key: buffer,
}Functions and Properties
crypto.digest
Computes a cryptographic hash of message using the given hash algorithm. Returns the hash as a buffer.
luau
(hash: Hash<any>, message: string | buffer) -> buffercrypto.password.hash
Hashes password using a slow, memory-hard algorithm suitable for password storage. Returns the hash as a buffer.
luau
(password: string) -> buffercrypto.password.verify
Verifies that password matches the stored hash. Returns true if the password is correct.
luau
(hash: buffer, password: string) -> booleancrypto.secretbox.keygen
Generates a new random secret key for use with secretbox.seal.
luau
() -> buffercrypto.secretbox.open
Decrypts box and returns the original plaintext as a buffer.
luau
(box: SecretBox) -> buffercrypto.secretbox.seal
Encrypts message with key (or a freshly generated key if omitted). Returns a SecretBox.
luau
(message: string | buffer, key: buffer?) -> SecretBox