Skip to content

Bcrypt

Password hashing using iterated HMAC-SHA256 with random salt.

Install

bash
wyn pkg install github.com/wynlang/bcrypt

Usage

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 verify

API

MethodDescription
Bcrypt.hash(password: string) -> stringHash with random salt, 10 rounds
Bcrypt.verify(password: string, hash: string) -> boolVerify password against hash

Hash Format

$wyn$10$<32-char-hex-salt>$<64-char-hex-hash>

MIT License