Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Namespace

pwhash

Public Namespace
std.crypto.pwhash
pub const pwhash = struct

A password hashing function derives a uniform key from low-entropy input material such as passwords. It is intentionally slow or expensive.

With the standard definition of a key derivation function, if a key space is small, an exhaustive search may be practical. Password hashing functions make exhaustive searches way slower or way more expensive, even when implemented on GPUs and ASICs, by using different, optionally combined strategies:

  • Requiring a lot of computation cycles to complete
  • Requiring a lot of memory to complete
  • Requiring multiple CPU cores to complete
  • Requiring cache-local data to complete in reasonable time
  • Requiring large static tables
  • Avoiding precomputations and time/memory tradeoffs
  • Requiring multi-party computations
  • Combining the input material with random per-entry data (salts), application-specific contexts and keys

Password hashing functions must be used whenever sensitive data has to be directly derived from a password.

Types

Values

File

crypto.zig:179
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
pub const pwhash = struct {
    pub const Encoding = enum {
        phc,
        crypt,
    };

    pub const Error = HasherError || error{AllocatorRequired};
    pub const HasherError = KdfError || phc_format.Error;
    pub const KdfError = errors.Error || std.mem.Allocator.Error || std.Thread.SpawnError || std.Io.Cancelable;

    pub const argon2 = @import("crypto/argon2.zig");
    pub const bcrypt = @import("crypto/bcrypt.zig");
    pub const scrypt = @import("crypto/scrypt.zig");
    pub const pbkdf2 = @import("crypto/pbkdf2.zig").pbkdf2;

    pub const phc_format = @import("crypto/phc_encoding.zig");
}