Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.crypto; | 5 part of dart.crypto; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Interface for cryptographic hash functions. | 8 * Interface for cryptographic hash functions. |
| 9 * | 9 * |
| 10 * The [add] method is used to add data to the hash. The [close] method | 10 * The [add] method is used to add data to the hash. The [close] method |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 /** | 117 /** |
| 118 * Convert a list of bytes (for example a message digest) into a hex | 118 * Convert a list of bytes (for example a message digest) into a hex |
| 119 * string. | 119 * string. |
| 120 */ | 120 */ |
| 121 static String bytesToHex(List<int> bytes) { | 121 static String bytesToHex(List<int> bytes) { |
| 122 return _CryptoUtils.bytesToHex(bytes); | 122 return _CryptoUtils.bytesToHex(bytes); |
| 123 } | 123 } |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * Converts a list of bytes (for example a message digest) into a | 126 * Converts a list of bytes (for example a message digest) into a |
| 127 * base64 encoded string optionally broken up in to lines of | 127 * base64 encoded string optionally broken up in to lines of 76 |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
Try to have the first line of the doc explain the
mdakin1
2013/03/21 15:27:15
Done,
| |
| 128 * [lineLength] chars separated by '\r\n'. | 128 * chars separated by '\r\n'. |
| 129 * Optionally generates url and filename safe encoding if [urlSafe] | |
| 130 * is set to true. | |
| 131 * Based on RFC 4686 http://tools.ietf.org/html/rfc4648 | |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
4686 -> 4648
mdakin1
2013/03/21 15:27:15
Done.
| |
| 132 * | |
| 129 */ | 133 */ |
| 130 static String bytesToBase64(List<int> bytes, [int lineLength]) { | 134 static String bytesToBase64(List<int> bytes, {bool urlSafe : false, bool addLi neSeparator : false}) { |
| 131 return _CryptoUtils.bytesToBase64(bytes, lineLength); | 135 return _CryptoUtils.bytesToBase64(bytes, urlSafe, addLineSeparator); |
| 132 } | 136 } |
| 137 | |
| 138 | |
| 139 /** | |
| 140 * Converts a base64 encoded String into list of bytes. Decoder ignores \r\n | |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
base64 -> Base64.
into list -> into a list
New par
mdakin1
2013/03/21 15:27:15
Done.
| |
| 141 * from input. By default also ignores all illegal chars unless | |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
\r\n from inpu -> "\r\n" sequences in the input.
B
mdakin1
2013/03/21 15:27:15
Done.
| |
| 142 * [ignoreErrors] is false. | |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
New paragraph here. Dartdoc flows like HTML, so th
mdakin1
2013/03/21 15:27:15
Done.
| |
| 143 * Accepts both url safe and unsafe base64 encoded strings. | |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
url -> URL
base64->Base 64 (just my preference, st
mdakin1
2013/03/21 15:27:15
Done.
| |
| 144 * Returns empty list if [input] is null. | |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
Returns empty -> Returns an empty
mdakin1
2013/03/21 15:27:15
Done.
| |
| 145 * Based on RFC 4686 http://tools.ietf.org/html/rfc4648 | |
|
Lasse Reichstein Nielsen
2013/03/21 14:06:38
4686 -> 4648
mdakin1
2013/03/21 15:27:15
Done.
| |
| 146 */ | |
| 147 static List<int> base64StringToBytes(String input, {bool ignoreErrors : true}) { | |
| 148 return _CryptoUtils.base64StringToBytes(input, ignoreErrors); | |
| 149 } | |
| 150 | |
| 133 } | 151 } |
| 134 | 152 |
| 135 /** | 153 /** |
| 136 * HashExceptions are thrown on invalid use of a Hash | 154 * HashExceptions are thrown on invalid use of a Hash |
| 137 * object. | 155 * object. |
| 138 */ | 156 */ |
| 139 class HashException { | 157 class HashException { |
| 140 HashException(String this.message); | 158 HashException(String this.message); |
| 141 toString() => "HashException: $message"; | 159 toString() => "HashException: $message"; |
| 142 String message; | 160 String message; |
| 143 } | 161 } |
| 144 | 162 |
| OLD | NEW |