File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,19 @@ Computes a k-bit non-cryptographic hash of the buffer using the FNV-1 algorithm.
66FNV-1 is a fast, non-cryptographic hash algorithm (suitable for checksums, not security)
77
88## Parameters
9- ` bits ` : specifies the output width (1-32 bits), determining
9+ * ** bits** : specifies the output width (1-32 bits), determining
1010the result range: 0 to 2^bits-1. For example, bits=5 produces values 0-31. Use this for
1111checksums, data validation, or collision detection. Not suitable for cryptographic purposes.
12+
13+ ## Returns
14+ a [ number] ( https://arcade.makecode.com/types/number ) of k-bit non-cryptographic hash.
15+
16+ ## Example
17+ Let us calculate the buffer's hash when the bits as 2 when the buffer's length is 30.
18+ ``` ts
19+ const buf = Buffer .create (0 );
20+ let hashValue = 0 ;
21+ if (buffer .length == 30 ) {
22+ hashValue = buffer .hash (2 );
23+ }
24+ ```
You can’t perform that action at this time.
0 commit comments