Skip to content

Instantly share code, notes, and snippets.

@bobslaede
Created October 13, 2010 12:26
Show Gist options
  • Save bobslaede/623920 to your computer and use it in GitHub Desktop.
Save bobslaede/623920 to your computer and use it in GitHub Desktop.
var shortUrlKey = function(salt,l,chars){
var out = '',
n = chars.length,
c,
i = 1;
while (i <= l) {
if (l > 0) {
c = ((salt / i) % n) >> 0;
out = chars[c] + out;
}
i++;
}
return out;
};
var i = 10;
var l = i+100;
var str = [];
var chars = 'abcdefghijklmnopqrstu0123456789'.split('');
var keyLength = 4;
while(i < l) {
str.push(shortUrlKey (i,keyLength,chars));
i++;
}
console.log(str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment