Last active
October 13, 2015 07:18
-
-
Save jason-s13r/4159752 to your computer and use it in GitHub Desktop.
just playing with things up to base90 :P
This file contains hidden or 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
hash = (() -> | |
_alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{}~"' | |
toNum = (c) -> if (_alphabet.indexOf c) == -1 then '' else _alphabet.indexOf c | |
(text, salt) -> | |
str = (text + salt).split "" | |
hashed = (str.map (c) -> toNum(c) << 0x501).join '' | |
return (hashed * 1).toString(36) | |
)() |
This file contains hidden or 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
var hash = (function() { | |
var toNum, _alphabet; | |
_alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{}~"'; | |
toNum = function(c) { | |
if ((_alphabet.indexOf(c)) === -1) { | |
return ''; | |
} else { | |
return _alphabet.indexOf(c); | |
} | |
}; | |
return function(text, salt) { | |
var hashed, str; | |
str = (text + salt).split(""); | |
hashed = (str.map(function(c) { | |
return toNum(c) << 0x501; | |
})).join(''); | |
return (hashed * 1).toString(36); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment