Skip to content

Commit 498e968

Browse files
Update bufferHash.md
1 parent b67f841 commit 498e968

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

docs/bufferHash.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ Computes a k-bit non-cryptographic hash of the buffer using the FNV-1 algorithm.
66
FNV-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
1010
the result range: 0 to 2^bits-1. For example, bits=5 produces values 0-31. Use this for
1111
checksums, 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+
```

0 commit comments

Comments
 (0)