Add utils
This commit is contained in:
parent
fe7ff5349d
commit
89156eb270
2 changed files with 14 additions and 1 deletions
|
|
@ -5,5 +5,5 @@ export function hash(content: Uint8Array): string {
|
|||
hash = (hash << 5) - hash + content[i];
|
||||
hash |= 0; // convert to 32bit integer
|
||||
}
|
||||
return hash.toString(64);
|
||||
return hash.toString(16);
|
||||
}
|
||||
13
plugin/src/utils/is-equal-bytes.ts
Normal file
13
plugin/src/utils/is-equal-bytes.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
export function isEqualBytes(bytes1: Uint8Array, bytes2: Uint8Array): boolean {
|
||||
if (bytes1.length !== bytes2.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < bytes1.length; i++) {
|
||||
if (bytes1[i] !== bytes2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue