Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Unified Diff: sdk/lib/crypto/crypto_base.dart

Issue 12534011: Add base64 decoder and change existing base64 encoder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: minor fix Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/crypto/crypto_utils.dart » ('j') | sdk/lib/crypto/crypto_utils.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9bb8734829660d2d61ab22defe7111bd51b3bee1 100644
--- a/sdk/lib/crypto/crypto_base.dart
+++ b/sdk/lib/crypto/crypto_base.dart
@@ -124,12 +124,30 @@ 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'.
+ * 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,
+ * chars separated by '\r\n'.
+ * Optionally generates url and filename safe encoding if [urlSafe]
+ * is set to true.
+ * 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.
+ *
*/
- 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 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.
+ * 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.
+ * [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.
+ * 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.
+ * 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.
+ * 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.
+ */
+ static List<int> base64StringToBytes(String input, {bool ignoreErrors : true}) {
+ return _CryptoUtils.base64StringToBytes(input, ignoreErrors);
+ }
+
}
/**
« no previous file with comments | « no previous file | sdk/lib/crypto/crypto_utils.dart » ('j') | sdk/lib/crypto/crypto_utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698