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

Unified Diff: packages/crypto/lib/src/hash.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/crypto/lib/src/digest_sink.dart ('k') | packages/crypto/lib/src/hash_sink.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/crypto/lib/src/hash.dart
diff --git a/packages/crypto/lib/src/hash.dart b/packages/crypto/lib/src/hash.dart
new file mode 100644
index 0000000000000000000000000000000000000000..14a2de69c6498f3b0e1d2c086c0bbeb1b2ed05a8
--- /dev/null
+++ b/packages/crypto/lib/src/hash.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:convert';
+
+import 'digest.dart';
+import 'digest_sink.dart';
+
+/// An interface for cryptographic hash functions.
+///
+/// Every hash is a converter that takes a list of ints and returns a single
+/// digest. When used in chunked mode, it will only ever add one digest to the
+/// inner [Sink].
+abstract class Hash extends Converter<List<int>, Digest> {
+ /// The internal block size of the hash in bytes.
+ ///
+ /// This is exposed for use by the `Hmac` class, which needs to know the block
+ /// size for the [Hash] it uses.
+ int get blockSize;
+
+ const Hash();
+
+ @override
+ Digest convert(List<int> data) {
+ var innerSink = new DigestSink();
+ var outerSink = startChunkedConversion(innerSink);
+ outerSink.add(data);
+ outerSink.close();
+ return innerSink.value;
+ }
+
+ @override
+ ByteConversionSink startChunkedConversion(Sink<Digest> sink);
+}
« no previous file with comments | « packages/crypto/lib/src/digest_sink.dart ('k') | packages/crypto/lib/src/hash_sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698