OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library crypto.utils; |
| 6 |
| 7 // Constants. |
| 8 const MASK_8 = 0xff; |
| 9 const MASK_32 = 0xffffffff; |
| 10 const BITS_PER_BYTE = 8; |
| 11 const BYTES_PER_WORD = 4; |
| 12 |
| 13 // Helper methods. |
| 14 int add32(x, y) => (x + y) & MASK_32; |
| 15 |
| 16 int roundUp(val, n) => (val + n - 1) & -n; |
| 17 |
| 18 // Helper functions used by more than one hasher. |
| 19 |
| 20 // Rotate left limiting to unsigned 32-bit values. |
| 21 int rotl32(int val, int shift) { |
| 22 var mod_shift = shift & 31; |
| 23 return ((val << mod_shift) & MASK_32) | |
| 24 ((val & MASK_32) >> (32 - mod_shift)); |
| 25 } |
OLD | NEW |