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

Unified Diff: packages/crypto/lib/src/digest.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/crypto.dart ('k') | packages/crypto/lib/src/digest_sink.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/crypto/lib/src/digest.dart
diff --git a/packages/crypto/lib/src/digest.dart b/packages/crypto/lib/src/digest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1ba4762f312c0a4428d1cb3906158513de1c1458
--- /dev/null
+++ b/packages/crypto/lib/src/digest.dart
@@ -0,0 +1,29 @@
+// 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 'package:collection/collection.dart';
+import 'package:convert/convert.dart';
+
+/// A message digest as computed by a `Hash` or `HMAC` function.
+class Digest {
+ /// The message digest as an array of bytes.
+ final List<int> bytes;
+
+ Digest(this.bytes);
+
+ /// Returns whether this is equal to another digest.
+ ///
+ /// This should be used instead of manual comparisons to avoid leaking
+ /// information via timing.
+ @override
+ bool operator ==(Object other) =>
+ other is Digest && const ListEquality().equals(bytes, other.bytes);
+
+ @override
+ int get hashCode => const ListEquality().hash(bytes);
+
+ /// The message digest as a string of hexadecimal digits.
+ @override
+ String toString() => hex.encode(bytes);
+}
« no previous file with comments | « packages/crypto/lib/crypto.dart ('k') | packages/crypto/lib/src/digest_sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698