Last active
November 14, 2017 17:36
-
-
Save SethVandebrooke/d98913beb2fba0876206b0ba6a84152a to your computer and use it in GitHub Desktop.
An excuse of a hash function: for hashing things you don't actually care about.
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
// Please note: while the returned hash would be a pain in the butt to decode, it does not ensure uniqueness for smaller strings. | |
// If you have a string at least 9 varying characters than it might be worth using. | |
function hash(s,base64){var a="";s.split('').forEach(e=>{a+=e.charCodeAt(0)>>2;});return !!base64?btoa(a):a;} | |
// Example: hash("mySuperSecretPassword",true); // Base64 | |
// Output: "MjczMDIwMjkyODI1MjgyMDI1MjQyODI1MjkyMDI0MjgyODI5MjcyODI1" | |
// Example: hash("mySuperSecretPassword"); | |
// Output: "273020292825282025242825292024282829272825" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment