Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Side by Side Diff: lib/src/hash.dart

Issue 2032903006: Stop implementing ChunkedConverter. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:convert'; 5 import 'dart:convert';
6 6
7 import 'digest.dart'; 7 import 'digest.dart';
8 import 'digest_sink.dart'; 8 import 'digest_sink.dart';
9 9
10 /// An interface for cryptographic hash functions. 10 /// An interface for cryptographic hash functions.
11 /// 11 ///
12 /// Every hash is a converter that takes a list of ints and returns a single 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 13 /// digest. When used in chunked mode, it will only ever add one digest to the
14 /// inner [Sink]. 14 /// inner [Sink].
15 abstract class Hash 15 abstract class Hash extends Converter<List<int>, Digest> {
16 extends ChunkedConverter<List<int>, Digest, List<int>, Digest> {
17 /// The internal block size of the hash in bytes. 16 /// The internal block size of the hash in bytes.
18 /// 17 ///
19 /// This is exposed for use by the [Hmac] class, which needs to know the block 18 /// This is exposed for use by the [Hmac] class, which needs to know the block
20 /// size for the [Hash] it uses. 19 /// size for the [Hash] it uses.
21 int get blockSize; 20 int get blockSize;
22 21
23 const Hash(); 22 const Hash();
24 23
25 Digest convert(List<int> data) { 24 Digest convert(List<int> data) {
26 var innerSink = new DigestSink(); 25 var innerSink = new DigestSink();
27 var outerSink = startChunkedConversion(innerSink); 26 var outerSink = startChunkedConversion(innerSink);
28 outerSink.add(data); 27 outerSink.add(data);
29 outerSink.close(); 28 outerSink.close();
30 return innerSink.value; 29 return innerSink.value;
31 } 30 }
32 31
33 ByteConversionSink startChunkedConversion(Sink<Digest> sink); 32 ByteConversionSink startChunkedConversion(Sink<Digest> sink);
34 } 33 }
OLDNEW
« CHANGELOG.md ('K') | « CHANGELOG.md ('k') | lib/src/hmac.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698