CryptoUtils class
Real cryptographic signing/verification for SIMOSEC requests, backed by
HMAC-SHA256 via package:crypto.
Callers build a canonical payload map containing everything the
signature should cover — in SIMOSEC's case, the request body, the
timestamp, and the userId (see SignatureLayer) — and sign/verify that
map as a whole. Keeping signing/verification generic over "a payload
map" (rather than hardcoding body/timestamp/userId in this file) makes
the utility reusable for other signed-message use cases too.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
signRequest(
String secret, Map< String, dynamic> payload) → String -
Computes an HMAC-SHA256 signature (as a lowercase hex string) over
payload, keyed withsecret. -
verifySignature(
String secret, Map< String, dynamic> payload, String? signature) → bool -
Verifies that
signatureis the correct HMAC-SHA256 signature forpayloadundersecret, using a constant-time comparison to avoid timing side-channels.