| 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 crypto.crypto_utils; | 5 library crypto.crypto_utils; |
| 6 | 6 |
| 7 import 'base64.dart'; | 7 import 'base64.dart'; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Utility methods for working with message digests. | 10 * Utility methods for working with message digests. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 * | 30 * |
| 31 * If [addLineSeparator] is true, the resulting string will be | 31 * If [addLineSeparator] is true, the resulting string will be |
| 32 * broken into lines of 76 characters, separated by "\r\n". | 32 * broken into lines of 76 characters, separated by "\r\n". |
| 33 * | 33 * |
| 34 * If [urlSafe] is true, the result is URL and filename safe. | 34 * If [urlSafe] is true, the result is URL and filename safe. |
| 35 * | 35 * |
| 36 * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648) | 36 * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648) |
| 37 * | 37 * |
| 38 */ | 38 */ |
| 39 static String bytesToBase64(List<int> bytes, | 39 static String bytesToBase64(List<int> bytes, |
| 40 [bool urlSafe = false, bool addLineSeparator = false]) { | 40 {bool urlSafe: false, bool addLineSeparator: false}) { |
| 41 return BASE64.encode(bytes, | 41 return BASE64.encode(bytes, |
| 42 urlSafe: urlSafe, addLineSeparator: addLineSeparator); | 42 urlSafe: urlSafe, addLineSeparator: addLineSeparator); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Converts a Base 64 encoded String into list of bytes. | 46 * Converts a Base 64 encoded String into list of bytes. |
| 47 * | 47 * |
| 48 * Decoder ignores "\r\n" sequences from input. | 48 * Decoder ignores "\r\n" sequences from input. |
| 49 * | 49 * |
| 50 * Accepts both URL safe and unsafe Base 64 encoded strings. | 50 * Accepts both URL safe and unsafe Base 64 encoded strings. |
| 51 * | 51 * |
| 52 * Throws a FormatException exception if input contains invalid characters. | 52 * Throws a FormatException exception if input contains invalid characters. |
| 53 * | 53 * |
| 54 * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648) | 54 * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648) |
| 55 */ | 55 */ |
| 56 static List<int> base64StringToBytes(String input) { | 56 static List<int> base64StringToBytes(String input) { |
| 57 return BASE64.decode(input); | 57 return BASE64.decode(input); |
| 58 } | 58 } |
| 59 } | 59 } |
| OLD | NEW |