Last active
August 29, 2015 14:01
-
-
Save maxkrieger/1146f90634401c03729b to your computer and use it in GitHub Desktop.
Make a hash out of thin air!
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
/* | |
>>>>>>>>>>>>>>>>> | |
ThinAirHash | |
>>>>>>>>>>>>>>>>> | |
use: | |
makeHash(length); | |
returns: | |
random hash consisting of up/lowercase letters and numbers 0-9 | |
*/ | |
function makeHash(length){ | |
var hash = ""; | |
var letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; | |
for(var c=0; c<length; c++){ | |
var whichone = Math.round(Math.random()*1); | |
if(whichone == 0){ | |
var char = Math.round(Math.random()*9); | |
} | |
if(whichone == 1){ | |
var char = letters[Math.round(Math.random()*50)]; | |
} | |
hash = hash + String(char); | |
} | |
return hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment