| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:convert'; |
| 6 |
| 7 import 'digest.dart'; |
| 8 import 'digest_sink.dart'; |
| 9 |
| 10 /// An interface for cryptographic hash functions. |
| 11 /// |
| 12 /// Every hash is a converter that takes a list of ints and returns a single |
| 13 /// digest. When used in chunked mode, it will only ever add one digest to the |
| 14 /// inner [Sink]. |
| 15 abstract class Hash extends Converter<List<int>, Digest> { |
| 16 /// The internal block size of the hash in bytes. |
| 17 /// |
| 18 /// This is exposed for use by the `Hmac` class, which needs to know the block |
| 19 /// size for the [Hash] it uses. |
| 20 int get blockSize; |
| 21 |
| 22 const Hash(); |
| 23 |
| 24 @override |
| 25 Digest convert(List<int> data) { |
| 26 var innerSink = new DigestSink(); |
| 27 var outerSink = startChunkedConversion(innerSink); |
| 28 outerSink.add(data); |
| 29 outerSink.close(); |
| 30 return innerSink.value; |
| 31 } |
| 32 |
| 33 @override |
| 34 ByteConversionSink startChunkedConversion(Sink<Digest> sink); |
| 35 } |
| OLD | NEW |