data password
Password hashing with scrypt (N = 2^15, r = 8, p = 1 by default). The result is one text,
$scrypt$ln=15,r=8,p=1$<salt>$<hash> (base64, no padding), that carries everything verify needs.
Example:
use std.crypto { password }
fn main() io, rand {
let stored = password.hash("correct horse")
print("{password.verify("correct horse", stored)} {password.verify("wrong", stored)}")
}Output
true false
pub(api) data passwordThread safety. pure functions apart from the random salt; safe from any task.
Since. 1.0.0-beta
Methods
hash | (pw: str) -> str randHashes a password with scrypt; the result carries the salt and the cost, so verify needs only the text. |
hashWith | (pw: str, logN: i64) -> str randlogN is the base-2 logarithm of the scrypt cost N (memory is 128 N 8 bytes); 10 is for tests only. |
verify | (pw: str, encoded: str) -> boolChecks pw against a text made by hash; a malformed text is simply false. |
Defined in: std/crypto/crypto.oxl:769