SecretBytes class final

Secret material with a definite end of life. wipe overwrites the bytes with zeros and every later access throws, so a key or password copy cannot linger on the Dart heap unnoticed. If the object is collected before wipe, the bytes are zeroed by a finalizer on a best-effort basis.

final secret = SecretBytes.copy(sharedSecret);
final key = secret.use((bytes) => lib.hkdfDerive(bytes, info: info));
secret.wipe();

Constructors

SecretBytes.copy(List<int> bytes)
A private copy of bytes; the caller still owns and should wipe the original.
factory
SecretBytes.take(Uint8List bytes)
Takes ownership of bytes without copying; wipe them through this.
factory

Properties

bytes → Uint8List
The live bytes, not a copy. Throws StateError after wipe.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isWiped → bool
Whether wipe ran.
no setter
length → int
Number of bytes.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

copy() → Uint8List
An independent copy; wipe it when done.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
use<T>(T action(Uint8List bytes)) → T
Runs action over the live bytes.
wipe() → void
Overwrites the bytes with zeros. Idempotent.

Operators

operator ==(Object other) → bool
The equality operator.
inherited