Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(675)

Unified Diff: lib/src/utils.dart

Issue 1348983002: Update documentation comments. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Code review changes Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/sha256.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 3f8a5c990c53277fb7ad60324e2c4d669124e721..f2f265db1830e66739c6a6fd4c04410181de2c17 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -4,20 +4,23 @@
library crypto.utils;
-// Constants.
+/// A bitmask that limits an integer to 8 bits.
const MASK_8 = 0xff;
+
+/// A bitmask that limits an integer to 32 bits.
const MASK_32 = 0xffffffff;
+
+/// The number of bits in a byte.
const BITS_PER_BYTE = 8;
+
+/// The number of bytes in a 32-bit word.
const BYTES_PER_WORD = 4;
-// Helper methods.
+/// Adds [x] and [y] with 32-bit overflow semantics.
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.
+/// Bitwise rotates [val] to the left by [shift], obeying 32-bit overflow
+/// semantics.
int rotl32(int val, int shift) {
var mod_shift = shift & 31;
return ((val << mod_shift) & MASK_32) |
« no previous file with comments | « lib/src/sha256.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698