Skip to content

Instantly share code, notes, and snippets.

@maxkrieger
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxkrieger/1146f90634401c03729b to your computer and use it in GitHub Desktop.
Save maxkrieger/1146f90634401c03729b to your computer and use it in GitHub Desktop.
Make a hash out of thin air!
/*
>>>>>>>>>>>>>>>>>
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