HashAlgorithm class abstract

A hash algorithm that produces a Hash.

Available algorithms

Example: simple usage

import 'package:cryptography/cryptography.dart';

void main() async {
  final algorithm = Sha256();
  final hash = await algorithm.hash([1,2,3]);
  print('Hash: ${hash.bytes}');
}

Example: hashing many chunks

import 'package:cryptography/cryptography.dart';

void main() async {
  // Create a sink
  final algorithm = Sha256();
  final sink = algorithm.newHashSink();

  // Add all parts
  sink.add(<int>[1,2,3]);
  sink.add(<int>[4,5]);

  // Calculate hash
  sink.close();
  final hash = await sink.hash();

  print('Hash: ${hash.bytes}');
}
Implementers

Constructors

HashAlgorithm()
const

Properties

blockLengthInBytes int
The internal block size in bytes. This information is required by some algorithms such as Hmac.
no setter
hashCode int
The hash code for this object.
no setteroverride
hashLengthInBytes int
Digest size in bytes.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

hash(List<int> input) Future<Hash>
Calculates hash for the argument.
override
newHashSink() HashSink
Constructs a sink for hashing chunks.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
toSync() DartHashAlgorithm
For synchronous computations, returns a pure Dart implementation of the hash algorithm.

Operators

operator ==(Object other) bool
The equality operator.
override