-
Notifications
You must be signed in to change notification settings - Fork 0
crypto_pwhash
Wrapper for the crypto_pwhash
functions.
https://libsodium.gitbook.io/doc/password_hashing/default_phf
local luasodium = require'luasodium'
local passwd = 'Correct horse battery staple'
local str = luasodium.crypto_pwhash_str(
passwd,
luasodium.crypto_pwhash_OPSLIMIT_SENSITIVE,
luasodium.crypto_pwhash_MEMLIMIT_SENSITIVE)
assert(luasodium.crypto_pwhash_str_verify(str, passwd) == true)
luasodium.crypto_pwhash_ALG_ARGON2I13
luasodium.crypto_pwhash_ALG_ARGON2ID13
luasodium.crypto_pwhash_ALG_DEFAULT
luasodium.crypto_pwhash_BYTES_MAX
luasodium.crypto_pwhash_BYTES_MIN
luasodium.crypto_pwhash_MEMLIMIT_INTERACTIVE
luasodium.crypto_pwhash_MEMLIMIT_MAX
luasodium.crypto_pwhash_MEMLIMIT_MIN
luasodium.crypto_pwhash_MEMLIMIT_MODERATE
luasodium.crypto_pwhash_MEMLIMIT_SENSITIVE
luasodium.crypto_pwhash_OPSLIMIT_INTERACTIVE
luasodium.crypto_pwhash_OPSLIMIT_MAX
luasodium.crypto_pwhash_OPSLIMIT_MIN
luasodium.crypto_pwhash_OPSLIMIT_MODERATE
luasodium.crypto_pwhash_OPSLIMIT_SENSITIVE
luasodium.crypto_pwhash_PASSWD_MAX
luasodium.crypto_pwhash_PASSWD_MIN
luasodium.crypto_pwhash_SALTBYTES
luasodium.crypto_pwhash_STRBYTES
luasodium.crypto_pwhash_STRPREFIX
- crypto_pwhash
- crypto_pwhash_str
- crypto_pwhash_str_verify
- crypto_pwhash_str_needs_rehash
- crypto_pwhash_scryptsalsa208sha256
- crypto_pwhash_scryptsalsa208sha256_str
- crypto_pwhash_scryptsalsa208sha256_str_verify
- crypto_pwhash_scryptsalsa208sha256_str_needs_rehash
syntax: string key = luasodium.crypto_pwhash(number length, string password, string salt, number opslimit, number memlimit [, number algorithm])
Derives a key
that's length
bytes long, from a given password
and
salt
, with the given limit of CPU opslimit
to perform and maximum
memory memlimit
(in bytes). An algorithm can be specified
with algorithm
(see the above constants for available choices).
syntax: string hash = luasodium.crypto_pwhash_str(string password, number opslimit, number memlimit)
Computes an ASCII-encoded hash and returns it as hash
for a given
password
, opslimit
, and memlimit
combination.
syntax: boolean success = luasodium.crypto_pwhash_str_verify(string hash, string password)
Verifies if hash
is valid for a given password
. Returns true
on
success.
syntax: boolean rehash_needed = luasodium_crypto_pwhash_str_needs_rehash(string hash, number opslimit, number memlimit)
Returns true
if a given hash
needs to be rehashed for a new opslimit
and memlimit
.
syntax: string key = luasodium.crypto_pwhash_scryptsalsa208sha256(number length, string password, string salt, number opslimit, number memlimit)
Derives a key
that's length
bytes long, from a given password
and
salt
, with the given limit of CPU opslimit
to perform and maximum
memory memlimit
(in bytes).
syntax: string hash = luasodium.crypto_pwhash_scryptsalsa208sha256_str(string password, number opslimit, number memlimit)
Computes an ASCII-encoded hash and returns it as hash
for a given
password
, opslimit
, and memlimit
combination.
syntax: boolean success = luasodium.crypto_pwhash_scryptsalsa208sha256_str_verify(string hash, string password)
Verifies if hash
is valid for a given password
. Returns true
on
success.
syntax: boolean rehash_needed = luasodium_crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(string hash, number opslimit, number memlimit)
Returns true
if a given hash
needs to be rehashed for a new opslimit
and memlimit
.