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

Unified Diff: lib/src/digest.dart

Issue 1355223002: Change Hash subclasses to be Converters. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Code review changes Created 5 years, 3 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 | « CHANGELOG.md ('k') | lib/src/digest_sink.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/digest.dart
diff --git a/lib/src/digest.dart b/lib/src/digest.dart
index 02af61461627af456ec9fbcd06fa0120ac0f0ecf..8dafcedbadb6745a1de6fd2856f0739b4c55d365 100644
--- a/lib/src/digest.dart
+++ b/lib/src/digest.dart
@@ -4,8 +4,6 @@
library crypto.digest;
-import 'dart:typed_data';
-
import 'crypto_utils.dart';
/// A message digest as computed by a [Hash] or [HMAC] function.
@@ -13,8 +11,7 @@ class Digest {
/// The message digest as an array of bytes.
final List<int> bytes;
- Digest(List<int> bytes)
- : bytes = new Uint8List.fromList(bytes);
+ Digest(this.bytes);
/// Returns whether this is equal to another digest.
///
@@ -22,11 +19,13 @@ class Digest {
/// information via timing.
bool operator ==(Object other) {
if (other is! Digest) return false;
- if (other.bytes.length != bytes.length) return false;
+
+ var digest = other as Digest;
+ if (digest.bytes.length != bytes.length) return false;
var result = 0;
for (var i = 0; i < bytes.length; i++) {
- result |= bytes[i] ^ other.bytes[i];
+ result |= bytes[i] ^ digest.bytes[i];
}
return result == 0;
}
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/digest_sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698