Skip to content

Instantly share code, notes, and snippets.

@matsilva
Last active August 29, 2015 14:27
Show Gist options
  • Save matsilva/0348626b975b49b56d55 to your computer and use it in GitHub Desktop.
Save matsilva/0348626b975b49b56d55 to your computer and use it in GitHub Desktop.
Trello decode hash solution
function hash (s){
var h = 7
var letters = 'acdegilmnoprstuw'
for(var i = 0; i < s.length; i++){
console.log(h + ' ' + s[i] + ' ' + letters.indexOf(s[i]))
h = (h*37 + letters.indexOf(s[i]))
}
return h
}
function decodeHash (hash){
var h = 7
var letters = 'acdegilmnoprstuw'
var hashstring = ''
var reduced = hash
while(reduced != 7 ){
for (var i= 0; i < letters.length; i++){
var hashReduced = (reduced ­ i)/37
if(hashReduced % 1 === 0 ){
hashstring += letters[i]
//lastSolvedHash
reduced = hashReduced
//console.log(reduced + ' ' + letters[i] + ' ' + i)
break;
}
}
console.log(reduced)
}
return console.log(hashstring.split('').reverse().join(''))
}
decodeHash(956446786872726)
// hash('leepadg')
@matsilva
Copy link
Author

This solution will decode the hash... or crash your machine ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment