Skip to content

crypto.password.hash

Hashes a password using a cryptographically strong, slow hash algorithm (e.g., Argon2).

Signature

luau
function hash(password: string, algorithm: PasswordHashAlgorithm?): string

Types

luau
type PasswordHashAlgorithm = "argon2id" | "bcrypt" | "scrypt"

Summary

Parameters

ParameterTypeDescription
passwordstringThe plain text password to hash.
algorithmPasswordHashAlgorithm?The password hashing algorithm to use (defaults to "argon2id").

Example

lua
local crypto = require("@runtime/crypto")

local hashed = crypto.password.hash("hunter2")
print(hashed) -- $argon2id$v=19$m=65536,t=3,p=4$...