• Pbkdf2 algorithm

    Parameters

    • password: Buffer

      Key. This is sensitive information. Do not write it in plaintext in the source code.

    • salt: Buffer

      Salt value. Note: For security purposes, the salt length should be greater than 8 bytes, and the salt should be a secure random number.

    • iterations: number

      Dieda number. Note: More than 1000 iterations are recommended.

    • keyLen: number

      Length of the generated hash key. Note: The length is less than 32 bytes, which may be insecure in some cases.

    • algorithm: string

      Indicates the hash algorithm name.

    Returns Buffer

    Example


    import * as crypto from 'crypto';
    import * as buffer from 'buffer';

    let password = buffer.from("**********");
    let salt = buffer.from("***********");

    let crypt = crypto.pbkdf2(password, salt, 1000, 32, crypto.Hashs.SHA1);
    console.log(crypt.toString(buffer.Encoding.Base64));