SHA-256 (FIPS 180-4) and HMAC-SHA-256 (RFC 2104) in plain Dart, for the framework's own needs on every platform (the VM, JavaScript and WebAssembly): a digest of a key, a keyed hash of an address. It has no dependency.
It is not made for passwords (use a PasswordEncoder of
spring_security_core), and it makes no promise about timing.
final digest = Sha256.digest(utf8.encode('abc'));
final tag = Sha256.hmac(utf8.encode(secret), utf8.encode('203.0.113.7'));
print(Sha256.hex(tag)); // 64 hexadecimal digits
Spring (Java): MessageDigest.getInstance("SHA-256") and
Mac.getInstance("HmacSHA256") of the JDK.
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
-
digest(
List< int> bytes) → Uint8List -
The SHA-256 digest of
bytes: 32 bytes. -
hex(
List< int> bytes) → String -
bytesas lower-case hexadecimal digits, two per byte. -
hmac(
List< int> key, List<int> message) → Uint8List -
The HMAC-SHA-256 of
messageunderkey: 32 bytes. Only who has the key can compute it, so the hash of a guessable value (an address) cannot be reversed by trying every value.
Constants
- digestLength → const int
- The length of a digest, in bytes.