Chromium Code Reviews| Index: sdk/lib/crypto/crypto_base.dart |
| diff --git a/sdk/lib/crypto/crypto_base.dart b/sdk/lib/crypto/crypto_base.dart |
| index d1666b51ed9a7bafb0a5537301fb92a67b2577d5..20f434408ccc327259350de74ad9da4a2e2f8f9b 100644 |
| --- a/sdk/lib/crypto/crypto_base.dart |
| +++ b/sdk/lib/crypto/crypto_base.dart |
| @@ -123,13 +123,45 @@ abstract class CryptoUtils { |
| } |
| /** |
| - * Converts a list of bytes (for example a message digest) into a |
| - * base64 encoded string optionally broken up in to lines of |
| - * [lineLength] chars separated by '\r\n'. |
| + * Converts a list of bytes into a Base 64 encoded string. |
| + * |
| + * The list can be any list of integers in the range 0..255, |
| + * for example a message digest. |
| + * |
| + * If [addLineSeparator] is true, the resulting string will be |
| + * broken into lines of 76 characters, separated by "\r\n". |
| + * |
| + * If [urlSafe] is true, the result is URL and filename safe. |
| + * |
| + * If [usePadding] is false, No extra padding characters ('=') are |
| + * appended to the output. |
| + * |
| + * Based on RFC 4648 http://tools.ietf.org/html/rfc4648 |
|
floitsch
2013/03/25 17:45:37
nit: I think Markdown has a way to specify URLs. N
mdakin1
2013/03/26 09:52:17
Done.
|
| + * |
| */ |
| - static String bytesToBase64(List<int> bytes, [int lineLength]) { |
| - return _CryptoUtils.bytesToBase64(bytes, lineLength); |
| + static String bytesToBase64(List<int> bytes, |
| + {bool urlSafe : false, |
| + bool addLineSeparator : false}) { |
| + return _CryptoUtils.bytesToBase64(bytes, |
| + urlSafe, |
| + addLineSeparator); |
| } |
| + |
| + |
| + /** |
| + * Converts a Base 64 encoded String into list of bytes. |
| + * |
| + * Decoder ignores "\r\n" sequences from input. By default it also ignores |
| + * all illegal characters unless [ignoreErrors] is false. |
| + * |
| + * Accepts both URL safe and unsafe Base 64 encoded strings. |
| + * |
| + * Based on RFC 4648 http://tools.ietf.org/html/rfc4648 |
|
floitsch
2013/03/25 17:45:37
ditto.
mdakin1
2013/03/26 09:52:17
Done.
|
| + */ |
| + static List<int> base64StringToBytes(String input, {bool ignoreErrors : true}) { |
| + return _CryptoUtils.base64StringToBytes(input, ignoreErrors); |
| + } |
| + |
| } |
| /** |