newHashSink abstract method

  1. @override
DartHashSink newHashSink()
override

Constructs a sink for hashing chunks.

Example

An example with Sha256:

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}');
}

Implementation

@override
DartHashSink newHashSink();