Skip to content
FutureBlitz

    Install

    Import std.crypto.passwords

    Argon2id

    std.crypto.passwords

    struct

    Public Struct Argon2id

    Argon2id (RFC 9106), a hash that takes memory as well as time.

    Examples

    Local kept = Argon2id.Hash("correct horse")
    Expect(kept.StartsWith("$argon2id$v=19$"))
    Expect(Argon2id.Verify("correct horse", kept))
    Expect(!Argon2id.Verify("wrong horse", kept))

    std/crypto/passwords.fb, line 34

    • Public Static Method Hash(password: String): String static method #

      The PHC string of password's hash, "$argon2id$v=19$m=19456,t=2,p=1$$", with a new 16-byte salt and OWASP's parameters: 19 MiB of memory, 2 passes, and 1 lane.

    • @PanicsAtCaller Public Static Method Hash(password: String, memory: Int, iterations: Int, parallelism: Int): String static method #

      The same, with memory KiB, iterations passes, and parallelism lanes. Panics unless parallelism is from 1 to 16777215, memory is at least 8 times parallelism, and iterations is 1 or more.

    • Public Static Method Verify(password: String, hash: String): Bool static method #

      Whether password is the one hash, a PHC string from Hash, was made from. A hash that isn't an Argon2id PHC string is no password's.

    • @PanicsAtCaller Public Static Method Derive(password: UInt8[], salt: UInt8[], memory: Int, iterations: Int, parallelism: Int, length: Int, secret: UInt8[] = [], associated: UInt8[] = []): UInt8[] static method #

      length bytes of key from password and salt, with those costs, and with secret, a key that isn't kept with the hash, and associated data, which can both be empty. Panics as Hash does, or unless salt is 8 bytes or more and length 4 or more.

    Report an issue with this page or with FutureBlitz on GitHub.