Add hash
This commit is contained in:
parent
9ce8245abc
commit
476c0ed672
1 changed files with 9 additions and 0 deletions
9
plugin/src/utils.ts
Normal file
9
plugin/src/utils.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
||||
export function hash(content: Uint8Array): string {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < content.length; i++) {
|
||||
hash = (hash << 5) - hash + content[i];
|
||||
hash |= 0; // convert to 32bit integer
|
||||
}
|
||||
return hash.toString(64);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue