Overwrites the value of the encrypted secret with random data.
Consumes a buffer of data that's intended to be secret.
Data to encrypt. The input buffer is overwritten with random data after it's encrypted and assigned internally.
Invokes a callback with a decrypted version of the buffer.
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!
T - The value of the callback of type T
Used to store and retrieve a sensitive information in memory. This is not meant for at rest encryption.
const sString: SecureBuffer = 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
return testReturnValue;
});