- Documentation
- Server functions
- passwordHash
Function
passwordHash
Creates a secure password hash (scrypt; the result starts with $scrypt$) to store in a database instead of the password. The same text gives a different hash every time; check it with passwordVerify. With a callback the hash goes to it.
Syntax
string passwordHash(string password [, string algorithm = "bcrypt", table options, function callback])Arguments
passwordstring- The password.
algorithmstring, optional = "bcrypt""scrypt";"bcrypt"is accepted but also produces scrypt.optionstable, optional{ cost = ... }.callbackfunction, optionalfunction(hash).
Returns
The hash or true with a callback.
Example
local stored = passwordHash("haslo123", "scrypt")
outputServerLog(tostring(passwordVerify("haslo123", stored))) -- true
Notes
No bcrypt. bcrypt hashes from other servers cannot be checked; after moving, players have to set their password again.