Created
October 13, 2010 12:26
-
-
Save bobslaede/623920 to your computer and use it in GitHub Desktop.
This file contains 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 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