OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 class _CryptoUtils { | 7 class _CryptoUtils { |
8 static String bytesToHex(List<int> bytes) { | 8 static String bytesToHex(List<int> bytes) { |
9 var result = new StringBuffer(); | 9 var result = new StringBuffer(); |
10 for (var part in bytes) { | 10 for (var part in bytes) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 int this._digestSizeInWords, | 173 int this._digestSizeInWords, |
174 bool this._bigEndianWords) | 174 bool this._bigEndianWords) |
175 : _pendingData = [] { | 175 : _pendingData = [] { |
176 _currentChunk = new List(_chunkSizeInWords); | 176 _currentChunk = new List(_chunkSizeInWords); |
177 _h = new List(_digestSizeInWords); | 177 _h = new List(_digestSizeInWords); |
178 } | 178 } |
179 | 179 |
180 // Update the hasher with more data. | 180 // Update the hasher with more data. |
181 add(List<int> data) { | 181 add(List<int> data) { |
182 if (_digestCalled) { | 182 if (_digestCalled) { |
183 throw new ArgumentError( | 183 throw new StateError( |
184 'Hash update method called after digest was retrieved'); | 184 'Hash update method called after digest was retrieved'); |
185 } | 185 } |
186 _lengthInBytes += data.length; | 186 _lengthInBytes += data.length; |
187 _pendingData.addAll(data); | 187 _pendingData.addAll(data); |
188 _iterate(); | 188 _iterate(); |
189 } | 189 } |
190 | 190 |
191 // Finish the hash computation and return the digest string. | 191 // Finish the hash computation and return the digest string. |
192 List<int> close() { | 192 List<int> close() { |
193 if (_digestCalled) { | 193 if (_digestCalled) { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 439 |
440 _h[0] = _add32(a, _h[0]); | 440 _h[0] = _add32(a, _h[0]); |
441 _h[1] = _add32(b, _h[1]); | 441 _h[1] = _add32(b, _h[1]); |
442 _h[2] = _add32(c, _h[2]); | 442 _h[2] = _add32(c, _h[2]); |
443 _h[3] = _add32(d, _h[3]); | 443 _h[3] = _add32(d, _h[3]); |
444 _h[4] = _add32(e, _h[4]); | 444 _h[4] = _add32(e, _h[4]); |
445 } | 445 } |
446 | 446 |
447 List<int> _w; | 447 List<int> _w; |
448 } | 448 } |
OLD | NEW |