Created
October 24, 2023 17:09
-
-
Save yuriuliam/aabb776241ca480519e0c3d0b7796643 to your computer and use it in GitHub Desktop.
A simple hash function to verify integrity between values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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