| 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 #library('dart:crypto'); | 5 #library('dart:crypto'); |
| 6 | 6 |
| 7 #import('dart:math'); | 7 #import('dart:math'); |
| 8 | 8 |
| 9 #source('crypto_utils.dart'); | 9 #source('crypto_utils.dart'); |
| 10 #source('hash_utils.dart'); | 10 #source('hash_utils.dart'); |
| 11 #source('hmac.dart'); | 11 #source('hmac.dart'); |
| 12 #source('md5.dart'); | 12 #source('md5.dart'); |
| 13 #source('sha1.dart'); | 13 #source('sha1.dart'); |
| 14 #source('sha256.dart'); | 14 #source('sha256.dart'); |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Interface for cryptographic hash functions. | 17 * Interface for cryptographic hash functions. |
| 18 * | 18 * |
| 19 * The [update] method is used to add data to the hash. The [digest] method | 19 * The [update] method is used to add data to the hash. The [digest] method |
| 20 * is used to extract the message digest. | 20 * is used to extract the message digest. |
| 21 * | 21 * |
| 22 * Once the [digest] method has been called no more data can be added using the | 22 * Once the [digest] method has been called no more data can be added using the |
| 23 * [update] method. If [update] is called after the first call to [digest] a | 23 * [update] method. If [update] is called after the first call to [digest] a |
| 24 * HashException is thrown. | 24 * HashException is thrown. |
| 25 * | 25 * |
| 26 * If multiple instances of a given Hash is needed the [newInstance] | 26 * If multiple instances of a given Hash is needed the [newInstance] |
| 27 * method can provide a new instance. | 27 * method can provide a new instance. |
| 28 */ | 28 */ |
| 29 interface Hash { | 29 abstract class Hash { |
| 30 /** | 30 /** |
| 31 * Add a list of bytes to the hash computation. | 31 * Add a list of bytes to the hash computation. |
| 32 */ | 32 */ |
| 33 Hash update(List<int> data); | 33 Hash update(List<int> data); |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Finish the hash computation and extract the message digest as | 36 * Finish the hash computation and extract the message digest as |
| 37 * a list of bytes. | 37 * a list of bytes. |
| 38 */ | 38 */ |
| 39 List<int> digest(); | 39 List<int> digest(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 /** | 122 /** |
| 123 * HashExceptions are thrown on invalid use of a Hash | 123 * HashExceptions are thrown on invalid use of a Hash |
| 124 * object. | 124 * object. |
| 125 */ | 125 */ |
| 126 class HashException { | 126 class HashException { |
| 127 HashException(String this.message); | 127 HashException(String this.message); |
| 128 toString() => "HashException: $message"; | 128 toString() => "HashException: $message"; |
| 129 String message; | 129 String message; |
| 130 } | 130 } |
| 131 | 131 |
| OLD | NEW |