• A utility function that takes a Buffer as argument and checks whether it is of size 32 bytes (i.e., 256 bits). If it is 32 bytes, it clones it and returns it. If it is less than 32 bytes, it clones it and pads it to the right with zeros to make it 32 bytes. If it is more than 32 bytes, it makes a clone of the first 32 bytes and returns it.

    Parameters

    • key: Buffer

      A Buffer instance (used as a password in this context).

    Returns Buffer

    A 256-bit Buffer instance containing the first 32 bytes of key if key is 32-bytes or more, else a copy of key's bytes with extra zeros to the right.

    Note

    This function is used internally by encrypt, encryptAsync, decrypt, and decryptAsync to prepare the password before encrypting and decrypting.

Generated using TypeDoc