File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ const FNV_PRIME = new Long(16777619, 0);
11
11
const OFFSET_BASIS = new Long ( 2166136261 , 0 ) ;
12
12
const FNV_MASK = new Long ( MASK_32 , 0 ) ;
13
13
14
+ /**
15
+ * Implementation of the FNV-1a hash for a 32-bit hash value
16
+ * Algorithm can be found here: http://www.isthe.com/chongo/tech/comp/fnv/#FNV-1a
17
+ * @ignore
18
+ */
14
19
function fnv1a32 ( input , encoding ) {
15
20
encoding = encoding || 'utf8' ;
16
21
const octets = Buffer . from ( input , encoding ) ;
@@ -24,6 +29,12 @@ function fnv1a32(input, encoding) {
24
29
return hash . getLowBitsUnsigned ( ) ;
25
30
}
26
31
32
+ /**
33
+ * Implements FNV-1a to generate 32-bit hash, then uses xor-folding
34
+ * to convert to a 24-bit hash. See here for more info:
35
+ * http://www.isthe.com/chongo/tech/comp/fnv/#xor-fold
36
+ * @ignore
37
+ */
27
38
function fnv1a24 ( input , encoding ) {
28
39
const _32bit = fnv1a32 ( input , encoding ) ;
29
40
const base = _32bit & MASK_24 ;
You can’t perform that action at this time.
0 commit comments