@@ -21,7 +21,7 @@ class _CryptoUtils {
2121 // -1 : '\r' or '\n'
2222 // 0 : = (Padding character).
2323 // >0 : Base 64 alphabet index of given byte.
24- static const List <int > _decodeTable = const [
24+ static const List <int > _decodeTable = [
2525 - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 1 , - 2 , - 2 , - 1 , - 2 , - 2 , //
2626 - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , //
2727 - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , 62 , - 2 , 62 , - 2 , 63 , //
@@ -40,18 +40,16 @@ class _CryptoUtils {
4040 - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2 , - 2
4141 ];
4242
43- static Random _rng = new Random .secure ();
44-
4543 static Uint8List getRandomBytes (int count) {
46- final Uint8List result = new Uint8List (count);
44+ final Uint8List result = Uint8List (count);
4745 for (int i = 0 ; i < count; i++ ) {
48- result[i] = _rng .nextInt (0xff );
46+ result[i] = Random . secure () .nextInt (0xff );
4947 }
5048 return result;
5149 }
5250
5351 static String bytesToHex (List <int > bytes) {
54- var result = new StringBuffer ();
52+ var result = StringBuffer ();
5553 for (var part in bytes) {
5654 result.write ('${part < 16 ? '0' : '' }${part .toRadixString (16 )}' );
5755 }
@@ -66,15 +64,15 @@ class _CryptoUtils {
6664 }
6765 final String lookup = urlSafe ? _encodeTableUrlSafe : _encodeTable;
6866 // Size of 24 bit chunks.
69- final int remainderLength = len.remainder (3 ) as int ;
67+ final int remainderLength = len.remainder (3 );
7068 final int chunkLength = len - remainderLength;
7169 // Size of base output.
7270 int outputLen = ((len ~ / 3 ) * 4 ) + ((remainderLength > 0 ) ? 4 : 0 );
7371 // Add extra for line separators.
7472 if (addLineSeparator) {
7573 outputLen += ((outputLen - 1 ) ~ / LINE_LENGTH ) << 1 ;
7674 }
77- List <int > out = new List <int >.filled (outputLen, 0 );
75+ List <int > out = List <int >.filled (outputLen, 0 );
7876
7977 // Encode 24 bit chunks.
8078 int j = 0 , i = 0 , c = 0 ;
@@ -111,14 +109,14 @@ class _CryptoUtils {
111109 out[j++ ] = PAD ;
112110 }
113111
114- return new String .fromCharCodes (out);
112+ return String .fromCharCodes (out);
115113 }
116114
117115 static List <int > base64StringToBytes (String input,
118116 [bool ignoreInvalidCharacters = true ]) {
119117 int len = input.length;
120118 if (len == 0 ) {
121- return new List <int >.empty ();
119+ return List <int >.empty ();
122120 }
123121
124122 // Count '\r', '\n' and illegal characters, For illegal characters,
@@ -129,13 +127,13 @@ class _CryptoUtils {
129127 if (c < 0 ) {
130128 extrasLen++ ;
131129 if (c == - 2 && ! ignoreInvalidCharacters) {
132- throw new FormatException ('Invalid character: ${input [i ]}' );
130+ throw FormatException ('Invalid character: ${input [i ]}' );
133131 }
134132 }
135133 }
136134
137135 if ((len - extrasLen) % 4 != 0 ) {
138- throw new FormatException ('''Size of Base 64 characters in Input
136+ throw FormatException ('''Size of Base 64 characters in Input
139137 must be a multiple of 4. Input: $input ''' );
140138 }
141139
@@ -147,7 +145,7 @@ class _CryptoUtils {
147145 if (currentCodeUnit == PAD ) padLength++ ;
148146 }
149147 int outputLen = (((len - extrasLen) * 6 ) >> 3 ) - padLength;
150- List <int > out = new List <int >.filled (outputLen, 0 );
148+ List <int > out = List <int >.filled (outputLen, 0 );
151149
152150 for (int i = 0 , o = 0 ; o < outputLen;) {
153151 // Accumulate 4 valid 6 bit Base 64 characters into an int.
@@ -183,20 +181,19 @@ abstract class _HashBase {
183181 final bool _bigEndianWords;
184182 int _lengthInBytes = 0 ;
185183 List <int > _pendingData;
186- List <int > _currentChunk;
187- List <int > _h;
184+ final List <int > _currentChunk;
185+ final List <int > _h;
188186 bool _digestCalled = false ;
189187
190188 _HashBase (this ._chunkSizeInWords, int digestSizeInWords, this ._bigEndianWords)
191189 : _pendingData = [],
192- _currentChunk = new List .filled (_chunkSizeInWords, 0 ),
193- _h = new List .filled (digestSizeInWords, 0 );
190+ _currentChunk = List .filled (_chunkSizeInWords, 0 ),
191+ _h = List .filled (digestSizeInWords, 0 );
194192
195193 // Update the hasher with more data.
196194 add (List <int > data) {
197195 if (_digestCalled) {
198- throw new StateError (
199- 'Hash update method called after digest was retrieved' );
196+ throw StateError ('Hash update method called after digest was retrieved' );
200197 }
201198 _lengthInBytes += data.length;
202199 _pendingData.addAll (data);
@@ -211,7 +208,7 @@ abstract class _HashBase {
211208 _digestCalled = true ;
212209 _finalizeData ();
213210 _iterate ();
214- assert (_pendingData.length == 0 );
211+ assert (_pendingData.isEmpty );
215212 return _resultAsBytes ();
216213 }
217214
@@ -227,8 +224,8 @@ abstract class _HashBase {
227224 _updateHash (List <int > m);
228225
229226 // Helper methods.
230- _add32 (x, y) => (x + y) & _MASK_32 ;
231- _roundUp (val, n) => (val + n - 1 ) & - n;
227+ int _add32 (int x, int y) => (x + y) & _MASK_32 ;
228+ int _roundUp (int val, int n) => (val + n - 1 ) & - n;
232229
233230 // Rotate left limiting to unsigned 32-bit values.
234231 int _rotl32 (int val, int shift) {
@@ -266,7 +263,7 @@ abstract class _HashBase {
266263
267264 // Convert a 32-bit word to four bytes.
268265 List <int > _wordToBytes (int word) {
269- List <int > bytes = new List .filled (_BYTES_PER_WORD , 0 );
266+ List <int > bytes = List .filled (_BYTES_PER_WORD , 0 );
270267 bytes[0 ] = (word >> (_bigEndianWords ? 24 : 0 )) & _MASK_8 ;
271268 bytes[1 ] = (word >> (_bigEndianWords ? 16 : 8 )) & _MASK_8 ;
272269 bytes[2 ] = (word >> (_bigEndianWords ? 8 : 16 )) & _MASK_8 ;
@@ -323,10 +320,10 @@ class _MD5 extends _HashBase {
323320
324321 // Returns a new instance of this Hash.
325322 _MD5 newInstance () {
326- return new _MD5 ();
323+ return _MD5 ();
327324 }
328325
329- static const _k = const [
326+ static const _k = [
330327 0xd76aa478 , 0xe8c7b756 , 0x242070db , 0xc1bdceee , 0xf57c0faf , 0x4787c62a , //
331328 0xa8304613 , 0xfd469501 , 0x698098d8 , 0x8b44f7af , 0xffff5bb1 , 0x895cd7be , //
332329 0x6b901122 , 0xfd987193 , 0xa679438e , 0x49b40821 , 0xf61e2562 , 0xc040b340 , //
@@ -340,7 +337,7 @@ class _MD5 extends _HashBase {
340337 0xf7537e82 , 0xbd3af235 , 0x2ad7d2bb , 0xeb86d391
341338 ];
342339
343- static const _r = const [
340+ static const _r = [
344341 7 , 12 , 17 , 22 , 7 , 12 , 17 , 22 , 7 , 12 , 17 , 22 , 7 , 12 , 17 , 22 , 5 , 9 , 14 , //
345342 20 , 5 , 9 , 14 , 20 , 5 , 9 , 14 , 20 , 5 , 9 , 14 , 20 , 4 , 11 , 16 , 23 , 4 , 11 , //
346343 16 , 23 , 4 , 11 , 16 , 23 , 4 , 11 , 16 , 23 , 6 , 10 , 15 , 21 , 6 , 10 , 15 , 21 , 6 , //
@@ -357,8 +354,8 @@ class _MD5 extends _HashBase {
357354 var c = _h[2 ];
358355 var d = _h[3 ];
359356
360- var t0;
361- var t1;
357+ int t0;
358+ int t1;
362359
363360 for (var i = 0 ; i < 64 ; i++ ) {
364361 if (i < 16 ) {
@@ -392,7 +389,7 @@ class _MD5 extends _HashBase {
392389
393390// The SHA1 hasher is used to compute an SHA1 message digest.
394391class _SHA1 extends _HashBase {
395- List <int > _w;
392+ final List <int > _w;
396393
397394 // Construct a SHA1 hasher object.
398395 _SHA1 ()
@@ -407,7 +404,7 @@ class _SHA1 extends _HashBase {
407404
408405 // Returns a new instance of this Hash.
409406 _SHA1 newInstance () {
410- return new _SHA1 ();
407+ return _SHA1 ();
411408 }
412409
413410 // Compute one iteration of the SHA1 algorithm with a chunk of
0 commit comments