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

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

Issue 1826543003: Update deprecations. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « lib/src/crypto_utils.dart ('k') | lib/src/hash.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'crypto_utils.dart'; 5 import 'package:convert/convert.dart';
6 6
7 /// A message digest as computed by a [Hash] or [HMAC] function. 7 /// A message digest as computed by a [Hash] or [HMAC] function.
8 class Digest { 8 class Digest {
9 /// The message digest as an array of bytes. 9 /// The message digest as an array of bytes.
10 final List<int> bytes; 10 final List<int> bytes;
11 11
12 Digest(this.bytes); 12 Digest(this.bytes);
13 13
14 /// Returns whether this is equal to another digest. 14 /// Returns whether this is equal to another digest.
15 /// 15 ///
16 /// This should be used instead of manual comparisons to avoid leaking 16 /// This should be used instead of manual comparisons to avoid leaking
17 /// information via timing. 17 /// information via timing.
18 bool operator ==(Object other) { 18 bool operator ==(Object other) {
19 if (other is! Digest) return false; 19 if (other is! Digest) return false;
20 20
21 var digest = other as Digest; 21 var digest = other as Digest;
22 if (digest.bytes.length != bytes.length) return false; 22 if (digest.bytes.length != bytes.length) return false;
23 23
24 var result = 0; 24 var result = 0;
25 for (var i = 0; i < bytes.length; i++) { 25 for (var i = 0; i < bytes.length; i++) {
26 result |= bytes[i] ^ digest.bytes[i]; 26 result |= bytes[i] ^ digest.bytes[i];
27 } 27 }
28 return result == 0; 28 return result == 0;
29 } 29 }
30 30
31 /// The message digest as a string of hexadecimal digits. 31 /// The message digest as a string of hexadecimal digits.
32 String toString() => CryptoUtils.bytesToHex(bytes); 32 String toString() => hex.encode(bytes);
33 } 33 }
OLDNEW
« no previous file with comments | « lib/src/crypto_utils.dart ('k') | lib/src/hash.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698