| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:convert'; | 5 import 'dart:convert'; |
| 6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 | 7 |
| 8 import 'package:charcode/ascii.dart'; | 8 import 'package:charcode/ascii.dart'; |
| 9 | 9 |
| 10 import 'decoder_sink.dart'; | 10 import 'decoder_sink.dart'; |
| 11 | 11 |
| 12 /// A mapping from ASCII character codes to their corresponding Base64 values. | 12 /// A mapping from ASCII character codes to their corresponding Base64 values. |
| 13 /// | 13 /// |
| 14 /// Characters with a value of `null` can't be decoded directly. This includes | 14 /// Characters with a value of `null` can't be decoded directly. This includes |
| 15 /// special values like CR, LF, `=`, and `%`. | 15 /// special values like CR, LF, `=`, and `%`. |
| 16 const _decodeTable = const [ | 16 const _decodeTable = const [ |
| 17 null, null, null, null, null, null, null, null, null, null, null, null, null, | 17 null, null, null, null, null, null, null, null, null, null, null, null, null, |
| 18 null, null, null, null, null, null, null, null, null, null, null, null, null, | 18 null, null, null, null, null, null, null, null, null, null, null, null, null, |
| 19 null, null, null, null, null, null, null, null, null, null, null, null, null, | 19 null, null, null, null, null, null, null, null, null, null, null, null, null, |
| 20 null, null, null, null, 62, null, 62, null, 63, 52, 53, 54, 55, 56, 57, 58, | 20 null, null, null, null, 62, null, 62, null, 63, 52, 53, 54, 55, 56, 57, 58, |
| 21 59, 60, 61, null, null, null, null, null, null, null, 0, 1, 2, 3, 4, 5, 6, 7, | 21 59, 60, 61, null, null, null, null, null, null, null, 0, 1, 2, 3, 4, 5, 6, 7, |
| 22 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, null, | 22 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, null, |
| 23 null, null, null, 63, null, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, | 23 null, null, null, 63, null, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 24 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 | 24 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 |
| 25 ]; | 25 ]; |
| 26 | 26 |
| 27 /// An encoder that converts [Base64][rfc] strings to sequences of bytes. | 27 /// This is deprecated. |
| 28 /// | 28 /// |
| 29 /// [rfc]: https://tools.ietf.org/html/rfc4648 | 29 /// Use the `Base64Decoder` class in `dart:convert` instead. |
| 30 @Deprecated("Will be removed in crypto 1.0.0.") |
| 30 class Base64Decoder extends Converter<String, List<int>> { | 31 class Base64Decoder extends Converter<String, List<int>> { |
| 31 const Base64Decoder(); | 32 const Base64Decoder(); |
| 32 | 33 |
| 33 List<int> convert(String input) { | 34 List<int> convert(String input) { |
| 34 if (input.length == 0) return new Uint8List(0); | 35 if (input.length == 0) return new Uint8List(0); |
| 35 | 36 |
| 36 // The length of the actual data sections in the input (not CRLFs). | 37 // The length of the actual data sections in the input (not CRLFs). |
| 37 var dataLength = 0; | 38 var dataLength = 0; |
| 38 | 39 |
| 39 // Count the data, and fail for invalid characters. | 40 // Count the data, and fail for invalid characters. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 119 } |
| 119 | 120 |
| 120 return out; | 121 return out; |
| 121 } | 122 } |
| 122 | 123 |
| 123 Base64DecoderSink startChunkedConversion(Sink<List<int>> sink) { | 124 Base64DecoderSink startChunkedConversion(Sink<List<int>> sink) { |
| 124 if (sink is! ByteConversionSink) sink = new ByteConversionSink.from(sink); | 125 if (sink is! ByteConversionSink) sink = new ByteConversionSink.from(sink); |
| 125 return new Base64DecoderSink(sink); | 126 return new Base64DecoderSink(sink); |
| 126 } | 127 } |
| 127 } | 128 } |
| OLD | NEW |