| OLD | NEW |
| 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 'dart:convert'; | 5 import 'dart:convert'; |
| 6 | 6 |
| 7 import 'digest.dart'; | 7 import 'digest.dart'; |
| 8 import 'digest_sink.dart'; | 8 import 'digest_sink.dart'; |
| 9 | 9 |
| 10 /// An interface for cryptographic hash functions. | 10 /// An interface for cryptographic hash functions. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 Digest convert(List<int> data) { | 33 Digest convert(List<int> data) { |
| 34 var innerSink = new DigestSink(); | 34 var innerSink = new DigestSink(); |
| 35 var outerSink = startChunkedConversion(innerSink); | 35 var outerSink = startChunkedConversion(innerSink); |
| 36 outerSink.add(data); | 36 outerSink.add(data); |
| 37 outerSink.close(); | 37 outerSink.close(); |
| 38 return innerSink.value; | 38 return innerSink.value; |
| 39 } | 39 } |
| 40 | 40 |
| 41 ByteConversionSink startChunkedConversion(Sink<Digest> sink); | 41 ByteConversionSink startChunkedConversion(Sink<Digest> sink); |
| 42 | 42 |
| 43 /// Returns a new instance of this hash function. | 43 /// This is deprecated. |
| 44 @Deprecated("Expires in 1.0.0. Use Hash.startChunkedConversion() instead.") | 44 /// |
| 45 /// Use [startChunkedConversion] instead. |
| 46 @Deprecated("Will be removed in crypto 1.0.0.") |
| 45 Hash newInstance(); | 47 Hash newInstance(); |
| 46 | 48 |
| 47 /// Add a list of bytes to the hash computation. | 49 /// This is deprecated. |
| 48 /// | 50 /// |
| 49 /// If [this] has already been closed, throws a [StateError]. | 51 /// Use [convert] or [startChunkedConversion] instead. |
| 50 @Deprecated("Expires in 1.0.0. Use Hash.convert() or " | 52 @Deprecated("Will be removed in crypto 1.0.0.") |
| 51 "Hash.startChunkedConversion() instead.") | |
| 52 void add(List<int> data) => _sink.add(data); | 53 void add(List<int> data) => _sink.add(data); |
| 53 | 54 |
| 54 /// Finish the hash computation and extract the message digest as a list of | 55 /// This is deprecated. |
| 55 /// bytes. | 56 /// |
| 56 @Deprecated("Expires in 1.0.0. Use Hash.convert() or " | 57 /// Use [convert] or [startChunkedConversion] instead. |
| 57 "Hash.startChunkedConversion() instead.") | 58 @Deprecated("Will be removed in crypto 1.0.0.") |
| 58 List<int> close() { | 59 List<int> close() { |
| 59 _sink.close(); | 60 _sink.close(); |
| 60 return _innerSink.value.bytes; | 61 return _innerSink.value.bytes; |
| 61 } | 62 } |
| 62 } | 63 } |
| OLD | NEW |