Used to store and retrieve a sensitive information in memory. This is not meant for at rest encryption.

const sString: SecureBuffer<string> = new SecureBuffer();
sString.consume(secretTextBuffer);
const value: string = sString.value((buffer: Buffer): string => {
const password: string = buffer.toString('utf8');
// doSomething with the password
// returns something of type <T>
return testReturnValue;
});

Type Parameters

  • T

Constructors

Methods

Constructors

Methods

  • Consumes a buffer of data that's intended to be secret.

    Parameters

    • buffer: Buffer

      Data to encrypt. The input buffer is overwritten with random data after it's encrypted and assigned internally.

    Returns void

  • Invokes a callback with a decrypted version of the buffer.

    Parameters

    • cb: DecipherCallback<T>

      The callback containing the decrypted buffer parameter that returns a desired. typed object. It's important to understand that once the callback goes out of scope the buffer parameters is overwritten with random data. Do not make a copy of this buffer and persist it!

    Returns Optional<T>