Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

strHash

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.

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.

bcrypt.strHash
pub fn strHash(
    password: []const u8,
    options: HashOptions,
    out: []u8,
    io: std.Io,
) Error![]const u8

File

lib/std/crypto/bcrypt.zig:793

Code

pub fn strHash(
    password: []const u8,
    options: HashOptions,
    out: []u8,
    io: std.Io,
) Error![]const u8 {
    switch (options.encoding) {
        .phc => return PhcFormatHasher.create(password, options.params, out, io),
        .crypt => return CryptFormatHasher.create(password, options.params, out, io),
    }
}