deno.land / std@0.157.0 / crypto / _fnv / fnv32.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Ported from Go:// https://github.com/golang/go/tree/go1.13.10/src/hash/fnv/fnv.go// Copyright 2011 The Go Authors. All rights reserved. BSD license.// https://github.com/golang/go/blob/master/LICENSE// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
import { mul32, swap32 } from "./util.ts";
const prime32 = 16777619;
export const fnv32 = (data: Uint8Array): ArrayBuffer => { let hash = 2166136261;
data.forEach((c) => { hash = mul32(hash, prime32); hash ^= c; });
return Uint32Array.from([swap32(hash)]).buffer;};
export const fnv32a = (data: Uint8Array): ArrayBuffer => { let hash = 2166136261;
data.forEach((c) => { hash ^= c; hash = mul32(hash, prime32); });
return Uint32Array.from([swap32(hash)]).buffer;};
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
4 months ago