number method
Gets unsiged integer of bitLength-bit from the message digest.
If endian is Endian.little, it will treat the digest bytes as a little
endian number; Otherwise, if endian is Endian.big, it will treat the
digest bytes as a big endian number.
Implementation
int number([int bitLength = 64, Endian endian = Endian.big]) {
if (bitLength < 8 || bitLength > 64 || (bitLength & 7) > 0) {
throw ArgumentError(
'Invalid bit length. '
'It must be a number between 8 to 64 and a multiple of 8.',
);
} else {
bitLength >>>= 3;
}
int result = 0;
int n = bytes.length;
if (endian == Endian.little) {
for (int i = (n > bitLength ? bitLength : n) - 1; i >= 0; i--) {
result <<= 8;
result |= bytes[i];
}
} else {
for (int i = n > bitLength ? n - bitLength : 0; i < n; i++) {
result <<= 8;
result |= bytes[i];
}
}
return result;
}