@@ -41,6 +41,22 @@ class HashDigest extends Object {
41
41
String base64 ({bool urlSafe = false , bool padding = false }) =>
42
42
toBase64 (bytes, padding: padding, url: urlSafe);
43
43
44
+ /// The message digest as a BigInt.
45
+ ///
46
+ /// If [endian] is [Endian.little] , it will treat the digest bytes as a little
47
+ /// endian number; Otherwise, if [endian] is [Endian.big] , it will treat the
48
+ /// digest bytes as a big endian number.
49
+ BigInt bigInt ({Endian endian = Endian .little}) =>
50
+ toBigInt (bytes, endian: endian);
51
+
52
+ /// Gets 64-bit unsiged integer from the message digest.
53
+ ///
54
+ /// If [endian] is [Endian.little] , it will treat the digest bytes as a little
55
+ /// endian number; Otherwise, if [endian] is [Endian.big] , it will treat the
56
+ /// digest bytes as a big endian number.
57
+ int number ([Endian endian = Endian .big]) =>
58
+ toBigInt (bytes, endian: endian).toUnsigned (64 ).toInt ();
59
+
44
60
/// The message digest as a string of ASCII alphabets.
45
61
String ascii () => cvt.ascii.decode (bytes);
46
62
@@ -50,25 +66,6 @@ class HashDigest extends Object {
50
66
/// Returns the digest in the given [encoding]
51
67
String to (cvt.Encoding encoding) => encoding.decode (bytes);
52
68
53
- /// Returns the least significant bytes as a number.
54
- ///
55
- /// If [endian] is big, it will return the last few bytes as a number;
56
- /// Otherwise, if [endian] is little, it will return the first few bytes
57
- /// as a number.
58
- int remainder ([Endian endian = Endian .big]) {
59
- int result = 0 ;
60
- if (endian == Endian .big) {
61
- for (int i = bytes.length - 1 , p = 0 ; i >= 0 ; -- i, p += 8 ) {
62
- result | = bytes[i] << p;
63
- }
64
- } else {
65
- for (int i = 0 , p = 0 ; i < 8 && i < bytes.length; ++ i, p += 8 ) {
66
- result | = bytes[i] << p;
67
- }
68
- }
69
- return result;
70
- }
71
-
72
69
@override
73
70
int get hashCode => bytes.hashCode;
74
71
0 commit comments