| Index: lib/src/utils.dart
|
| diff --git a/lib/src/utils.dart b/lib/src/utils.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3f8a5c990c53277fb7ad60324e2c4d669124e721
|
| --- /dev/null
|
| +++ b/lib/src/utils.dart
|
| @@ -0,0 +1,25 @@
|
| +// Copyright (c) 2015, 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.
|
| +
|
| +library crypto.utils;
|
| +
|
| +// Constants.
|
| +const MASK_8 = 0xff;
|
| +const MASK_32 = 0xffffffff;
|
| +const BITS_PER_BYTE = 8;
|
| +const BYTES_PER_WORD = 4;
|
| +
|
| +// Helper methods.
|
| +int add32(x, y) => (x + y) & MASK_32;
|
| +
|
| +int roundUp(val, n) => (val + n - 1) & -n;
|
| +
|
| +// Helper functions used by more than one hasher.
|
| +
|
| +// Rotate left limiting to unsigned 32-bit values.
|
| +int rotl32(int val, int shift) {
|
| + var mod_shift = shift & 31;
|
| + return ((val << mod_shift) & MASK_32) |
|
| + ((val & MASK_32) >> (32 - mod_shift));
|
| +}
|
|
|