TomProtectedValue class final
A secret in memory: reveal gives the plaintext, digest identifies it.
The bytes can still be read by a determined caller; what this changes is
where the read is visible. Every place the plaintext leaves the object
is a call to reveal, which a reader can search for, and every place that
would leak it by accident — toString() in a log line, an interpolated
map, jsonEncode, a merge comparison — gets the mask, the digest or an
error instead.
The plaintext is kept XOR-ed with a per-instance random salt, so it is not in memory as one contiguous string between reads. Equality is by digest, so "same secret or not" never needs the plaintext.
Constructors
- TomProtectedValue.of(String secret)
-
Protects
secret. TheStringhanded in is the caller's to drop.factory
Properties
- digest → String
-
The SHA-256 hex of the plaintext's UTF-8 bytes.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isEmpty → bool
-
no setter
- length → int
-
The plaintext's length in UTF-8 bytes — zero for an empty secret.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reveal(
) → String - The plaintext. The one accessor — every call site is a place the secret is deliberately read.
-
toString(
) → String -
Never the secret: the mask.
override
Operators
-
operator ==(
Object other) → bool -
By digest: two values protecting the same secret are equal.
override