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

Unified Diff: sdk/lib/io/base64.dart

Issue 15298004: Use dart:crypto's Base64 methods in dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/io/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/base64.dart
diff --git a/sdk/lib/io/base64.dart b/sdk/lib/io/base64.dart
deleted file mode 100644
index 1469c8d1190236ab62e0e1dbdee360d51ce38a7d..0000000000000000000000000000000000000000
--- a/sdk/lib/io/base64.dart
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of dart.io;
-
-class _Base64 {
- static const List<String> _encodingTable = const [
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
- 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', '+', '/'];
-
- /**
- * Base64 transfer encoding for MIME (RFC 2045)
- */
- static String _encode(List<int> data) {
- List<String> characters = new List<String>();
- int i;
- for (i = 0; i + 3 <= data.length; i += 3) {
- int value = 0;
- value |= data[i + 2];
- value |= data[i + 1] << 8;
- value |= data[i] << 16;
- for (int j = 0; j < 4; j++) {
- int index = (value >> ((3 - j) * 6)) & ((1 << 6) - 1);
- characters.add(_encodingTable[index]);
- }
- }
- // Remainders.
- if (i + 2 == data.length) {
- int value = 0;
- value |= data[i + 1] << 8;
- value |= data[i] << 16;
- for (int j = 0; j < 3; j++) {
- int index = (value >> ((3 - j) * 6)) & ((1 << 6) - 1);
- characters.add(_encodingTable[index]);
- }
- characters.add("=");
- } else if (i + 1 == data.length) {
- int value = 0;
- value |= data[i] << 16;
- for (int j = 0; j < 2; j++) {
- int index = (value >> ((3 - j) * 6)) & ((1 << 6) - 1);
- characters.add(_encodingTable[index]);
- }
- characters.add("=");
- characters.add("=");
- }
- StringBuffer output = new StringBuffer();
- for (i = 0; i < characters.length; i++) {
- if (i > 0 && i % 76 == 0) {
- output.write("\r\n");
- }
- output.write(characters[i]);
- }
- return output.toString();
- }
-
-
- /**
- * Base64 transfer decoding for MIME (RFC 2045).
- */
- static List<int> _decode(String data) {
- List<int> result = new List<int>();
- int padCount = 0;
- int charCount = 0;
- int value = 0;
- for (int i = 0; i < data.length; i++) {
- int char = data.codeUnitAt(i);
- if (65 <= char && char <= 90) { // "A" - "Z".
- value = (value << 6) | char - 65;
- charCount++;
- } else if (97 <= char && char <= 122) { // "a" - "z".
- value = (value << 6) | char - 97 + 26;
- charCount++;
- } else if (48 <= char && char <= 57) { // "0" - "9".
- value = (value << 6) | char - 48 + 52;
- charCount++;
- } else if (char == 43) { // "+".
- value = (value << 6) | 62;
- charCount++;
- } else if (char == 47) { // "/".
- value = (value << 6) | 63;
- charCount++;
- } else if (char == 61) { // "=".
- value = (value << 6);
- charCount++;
- padCount++;
- }
- if (charCount == 4) {
- result.add((value & 0xFF0000) >> 16);
- if (padCount < 2) {
- result.add((value & 0xFF00) >> 8);
- }
- if (padCount == 0) {
- result.add(value & 0xFF);
- }
- charCount = 0;
- value = 0;
- }
- }
- return result;
- }
-}
« no previous file with comments | « no previous file | sdk/lib/io/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698