Bcrypt
Password hashing using iterated HMAC-SHA256 with random salt.
Install
bash
wyn pkg install github.com/wynlang/bcryptUsage
wyn
// Hash a password
var hashed = Bcrypt.hash("mypassword")
// Verify a password
if Bcrypt.verify("mypassword", hashed) {
println("correct")
}
// Two hashes of the same password differ (random salt)
var h1 = Bcrypt.hash("secret")
var h2 = Bcrypt.hash("secret")
// h1 != h2, but both verifyAPI
| Method | Description |
|---|---|
Bcrypt.hash(password: string) -> string | Hash with random salt, 10 rounds |
Bcrypt.verify(password: string, hash: string) -> bool | Verify password against hash |
Hash Format
$wyn$10$<32-char-hex-salt>$<64-char-hex-hash>