Cell API
    Preparing search index...

    Class Pbkdf2PasswordEncoder

    Password hashes with PBKDF2-HMAC-SHA256 on node:crypto, compared in constant time.

    New hashes: pbkdf2-sha256$<iterations>$<salt, base64>$<key, base64> with 600000 iterations, a 16-byte random salt (followed by the UTF-8 bytes of secret when one is set) and a 32-byte key.

    Legacy hashes (no prefix), as the crypto-js 4.2.0 implementation of 4.x stored them, keep matching: optionally base64 of a text that is a 16-character hex salt followed by the hex key; the key is PBKDF2(password, salt + String(secret)) with SHA-256, iterations (default 250000) and keySize words (default 4). Without a secret the salt text ends in undefined, which is how those hashes were made. Hashes made with crypto-js 4.1 or older (SHA-1, 1 iteration) are not supported. needsUpgrade is true for legacy hashes, so a login replaces them with a new hash.

    Implements

    Index
    options: Pbkdf2PasswordEncoderOptions | undefined
    ITERATIONS: 600000
    KEY_BYTES: 32
    LEGACY_ITERATIONS: 250000
    LEGACY_KEY_SIZE: 4
    LEGACY_SALT_LENGTH: 16
    PREFIX: "pbkdf2-sha256" = 'pbkdf2-sha256'
    SALT_BYTES: 16
    • The text the crypto-js implementation stored (before the optional base64): salt + hex key.

      Parameters

      • rawPassword: string
      • salt: string

      Returns Promise<string>

    • Whether a stored hash should be replaced by encode() of the password once it matched (a legacy format, or weaker parameters than new hashes get). Login does so when the UserService can store passwords (UserService.updatePassword).

      Parameters

      • encodedPassword: string

      Returns boolean