Skip to content
FutureBlitz

    Install

    Import std.crypto.derive

    Pbkdf2

    std.crypto.derive

    struct

    Public Struct Pbkdf2

    PBKDF2 (RFC 8018) with HMAC: length bytes of key from password and salt, in iterations rounds, which make a guess at the password cost that many. For keeping passwords, Argon2id is stronger, since it needs memory too. Each panics unless iterations is 1 or more and length isn't negative.

    Examples

    Local salt = SecureRandom.Bytes(16)
    Local key = Pbkdf2.Sha256("correct horse", salt, 1000, 32)
    Expect(key.Count == 32)
    Expect(key == Pbkdf2.Sha256("correct horse", salt, 1000, 32))

    std/crypto/derive.fb, line 107

    • @PanicsAtCaller Public Static Method Sha1(password: String, salt: UInt8[], iterations: Int, length: Int): UInt8[] static method #

      By SHA-1, for the formats that ask for it.

    • @PanicsAtCaller Public Static Method Sha1(password: UInt8[], salt: UInt8[], iterations: Int, length: Int): UInt8[] static method #

      A key derived from the bytes of password by SHA-1, as the one that takes a String does.

    • @PanicsAtCaller Public Static Method Sha256(password: String, salt: UInt8[], iterations: Int, length: Int): UInt8[] static method #

      A key from password and salt, in iterations rounds of HMAC-SHA256.

    • @PanicsAtCaller Public Static Method Sha256(password: UInt8[], salt: UInt8[], iterations: Int, length: Int): UInt8[] static method #

      A key derived from the bytes of password by SHA-256, as the one that takes a String does.

    • @PanicsAtCaller Public Static Method Sha512(password: String, salt: UInt8[], iterations: Int, length: Int): UInt8[] static method #

      A key from password and salt, in iterations rounds of HMAC-SHA512.

    • @PanicsAtCaller Public Static Method Sha512(password: UInt8[], salt: UInt8[], iterations: Int, length: Int): UInt8[] static method #

      A key derived from the bytes of password by SHA-512, as the one that takes a String does.

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