OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library crypto.hash; |
| 6 |
| 7 /** |
| 8 * Interface for cryptographic hash functions. |
| 9 * |
| 10 * The [add] method is used to add data to the hash. The [close] method |
| 11 * is used to extract the message digest. |
| 12 * |
| 13 * Once the [close] method has been called no more data can be added using the |
| 14 * [add] method. If [add] is called after the first call to [close] a |
| 15 * HashException is thrown. |
| 16 * |
| 17 * If multiple instances of a given Hash is needed the [newInstance] |
| 18 * method can provide a new instance. |
| 19 */ |
| 20 // TODO(floitsch): make Hash implement Sink, EventSink or similar. |
| 21 abstract class Hash { |
| 22 /** |
| 23 * Add a list of bytes to the hash computation. |
| 24 */ |
| 25 void add(List<int> data); |
| 26 |
| 27 /** |
| 28 * Finish the hash computation and extract the message digest as |
| 29 * a list of bytes. |
| 30 */ |
| 31 List<int> close(); |
| 32 |
| 33 /** |
| 34 * Returns a new instance of this hash function. |
| 35 */ |
| 36 Hash newInstance(); |
| 37 |
| 38 /** |
| 39 * Internal block size of the hash in bytes. |
| 40 * |
| 41 * This is exposed for use by the HMAC class which needs to know the |
| 42 * block size for the [Hash] it is using. |
| 43 */ |
| 44 int get blockSize; |
| 45 } |
OLD | NEW |