Skip to content

Instantly share code, notes, and snippets.

@yuriuliam
Created October 24, 2023 17:09
Show Gist options
  • Save yuriuliam/aabb776241ca480519e0c3d0b7796643 to your computer and use it in GitHub Desktop.
Save yuriuliam/aabb776241ca480519e0c3d0b7796643 to your computer and use it in GitHub Desktop.
A simple hash function to verify integrity between values
const hash = (str: string) => {
let value = 0;
for (let i = 0; i < str.length; i += 1) {
const current = str.charCodeAt(i);
value += current << (i % 16);
}
return value.toString(16).padStart(16, '0');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment