Skip to content

Instantly share code, notes, and snippets.

@jason-s13r
Last active October 13, 2015 07:18
Show Gist options
  • Save jason-s13r/4159752 to your computer and use it in GitHub Desktop.
Save jason-s13r/4159752 to your computer and use it in GitHub Desktop.
just playing with things up to base90 :P
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)
)()
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