Skip to content

Instantly share code, notes, and snippets.

@tjstebbing
Created January 1, 2015 12:18
Show Gist options
  • Select an option

  • Save tjstebbing/442957697c8cff0eaa69 to your computer and use it in GitHub Desktop.

Select an option

Save tjstebbing/442957697c8cff0eaa69 to your computer and use it in GitHub Desktop.
function numberToToken(int) {
return Number('10000'+int).toString(36);
}
function tokenToNumber(token) {
return Number((parseInt(token, 36)+'').slice(4));
}
var num = 123;
console.log('starting with', num);
var token = numberToToken(num);
console.log('makes token', token);
console.log('and back to', tokenToNumber(token));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment