| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 | 7 |
| 8 import 'digest.dart'; | 8 import 'digest.dart'; |
| 9 import 'hash.dart'; | 9 import 'hash.dart'; |
| 10 import 'hash_sink.dart'; | 10 import 'hash_sink.dart'; |
| 11 import 'utils.dart'; | 11 import 'utils.dart'; |
| 12 | 12 |
| 13 /// An instance of [MD5]. | 13 /// An instance of [MD5]. |
| 14 /// | 14 /// |
| 15 /// This instance provides convenient access to the [MD5][rfc] hash function. | 15 /// This instance provides convenient access to the [MD5][rfc] hash function. |
| 16 /// | 16 /// |
| 17 /// [rfc]: https://tools.ietf.org/html/rfc1321 | 17 /// [rfc]: https://tools.ietf.org/html/rfc1321 |
| 18 /// | 18 /// |
| 19 /// **Warning**: MD5 has known collisions and should only be used when required | 19 /// **Warning**: MD5 has known collisions and should only be used when required |
| 20 /// for backwards compatibility. | 20 /// for backwards compatibility. |
| 21 final md5 = new MD5(); | 21 final md5 = new MD5._(); |
| 22 | 22 |
| 23 /// An implementation of the [MD5][rfc] hash function. | 23 /// An implementation of the [MD5][rfc] hash function. |
| 24 /// | 24 /// |
| 25 /// [rfc]: https://tools.ietf.org/html/rfc1321 | 25 /// [rfc]: https://tools.ietf.org/html/rfc1321 |
| 26 /// | 26 /// |
| 27 /// **Warning**: MD5 has known collisions and should only be used when required | 27 /// **Warning**: MD5 has known collisions and should only be used when required |
| 28 /// for backwards compatibility. | 28 /// for backwards compatibility. |
| 29 /// | 29 /// |
| 30 /// Note that it's almost always easier to use [md5] rather than creating a new | 30 /// Note that it's almost always easier to use [md5] rather than creating a new |
| 31 /// instance. | 31 /// instance. |
| 32 class MD5 extends Hash { | 32 class MD5 extends Hash { |
| 33 final int blockSize = 16 * bytesPerWord; | 33 final int blockSize = 16 * bytesPerWord; |
| 34 | 34 |
| 35 /// This constructor is deprecated. | 35 MD5._(); |
| 36 /// | |
| 37 /// Use [md5] instead. | |
| 38 @Deprecated("Will be removed in crypto 1.0.0.") | |
| 39 MD5(); | |
| 40 | |
| 41 MD5 newInstance() => new MD5(); | |
| 42 | 36 |
| 43 ByteConversionSink startChunkedConversion(Sink<Digest> sink) => | 37 ByteConversionSink startChunkedConversion(Sink<Digest> sink) => |
| 44 new ByteConversionSink.from(new _MD5Sink(sink)); | 38 new ByteConversionSink.from(new _MD5Sink(sink)); |
| 45 } | 39 } |
| 46 | 40 |
| 47 /// Data from a non-linear mathematical function that functions as | 41 /// Data from a non-linear mathematical function that functions as |
| 48 /// reproducible noise. | 42 /// reproducible noise. |
| 49 const _noise = const [ | 43 const _noise = const [ |
| 50 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, | 44 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, |
| 51 0xa8304613, 0xfd469501, 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, | 45 0xa8304613, 0xfd469501, 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 _shiftAmounts[i])); | 115 _shiftAmounts[i])); |
| 122 a = temp; | 116 a = temp; |
| 123 } | 117 } |
| 124 | 118 |
| 125 digest[0] = add32(a, digest[0]); | 119 digest[0] = add32(a, digest[0]); |
| 126 digest[1] = add32(b, digest[1]); | 120 digest[1] = add32(b, digest[1]); |
| 127 digest[2] = add32(c, digest[2]); | 121 digest[2] = add32(c, digest[2]); |
| 128 digest[3] = add32(d, digest[3]); | 122 digest[3] = add32(d, digest[3]); |
| 129 } | 123 } |
| 130 } | 124 } |
| OLD | NEW |