Struct SecretBuffer

Buffer for a password, token or other credential value.

struct SecretBuffer;

Create a SecretBuffer before passing a secret to a credential store. Use withBytes() only when an API actually needs the bytes, and keep that work inside the callback.

SecretBuffer cannot be copied accidentally. Call clear() when the application no longer needs the value and wants to release it immediately.

Constructors

NameDescription
this (source) Create a secret buffer from bytes you already have.

Properties

NameTypeDescription
empty[get] boolWhether this secret currently contains no bytes.
length[get] ulongNumber of bytes in this secret.

Methods

NameDescription
clear () Clear the secret and make this buffer empty.
withBytes (callback) Use the secret bytes for one operation.

Aliases

NameDescription
~this

Examples

auto token = SecretBuffer(tokenBytes);

CredentialHandle handle;
store.save(token, handle);

token.clear();