Functions

fn bcrypt(password: []const u8, salt: [salt_length]u8, params: Params) [dk_length]u8

Compute a hash of a password using 2^rounds_log rounds of the bcrypt key stretch…

Compute a hash of a password using 2^rounds_log rounds of the bcrypt key stretching function. bcrypt is a computationally expensive and cache-hard function, explicitly designed to slow down exhaustive searches.

The function returns the hash as a dk_length byte array, that doesn’t include anything besides the hash output.

For a generic key-derivation function, use bcrypt.pbkdf() instead.

IMPORTANT: by design, bcrypt silently truncates passwords to 72 bytes. If this is an issue for your application, use bcryptWithoutTruncation instead.

fn bcryptWithoutTruncation(password: []const u8, salt: [salt_length]u8, params: Params) [dk_length]u8

Compute a hash of a password using 2^rounds_log rounds of the bcrypt key stretch…

Compute a hash of a password using 2^rounds_log rounds of the bcrypt key stretching function. bcrypt is a computationally expensive and cache-hard function, explicitly designed to slow down exhaustive searches.

The function returns the hash as a dk_length byte array, that doesn’t include anything besides the hash output.

For a generic key-derivation function, use bcrypt.pbkdf() instead.

This function is identical to bcrypt, except that it doesn’t silently truncate passwords. Instead, passwords longer than 72 bytes are pre-hashed using HMAC-SHA512 before being passed to bcrypt.

fn pbkdf(pass: []const u8, salt: []const u8, key: []u8, rounds: u32) !void

bcrypt-pbkdf is a key derivation function based on bcrypt. This is the function…

bcrypt-pbkdf is a key derivation function based on bcrypt. This is the function used in OpenSSH to derive encryption keys from passphrases.

This implementation is compatible with the OpenBSD implementation (https://github.com/openbsd/src/blob/master/lib/libutil/bcrypt_pbkdf.c).

Unlike the password hashing function bcrypt, this function doesn’t silently truncate passwords longer than 72 bytes.

fn strHash(password: []const u8, options: HashOptions, out: []u8) Error![]const u8

Compute a hash of a password using 2^rounds_log rounds of the bcrypt key stretch…

Compute a hash of a password using 2^rounds_log rounds of the bcrypt key stretching function. bcrypt is a computationally expensive and cache-hard function, explicitly designed to slow down exhaustive searches.

The function returns a string that includes all the parameters required for verification.

IMPORTANT: by design, bcrypt silently truncates passwords to 72 bytes. If this is an issue for your application, set the silently_truncate_password option to false.

fn strVerify(str: []const u8, password: []const u8, options: VerifyOptions) Error!void

Verify that a previously computed hash is valid for a given password.

Values

hash_length
usize

Length (in bytes) of a password hash in crypt encoding