BEHOLD! THE ULTIMATE RANDOM STRING MAKER 9001!
Do you want random strings to the extreme?! Do you crave the random goodness in favor of something better than what you see elsewhere?! Are you tired of all these weak answers out there saying they solve this problem or that without having a problem of their own?! ARE YOU MISSING A COMBO OF NUMBERS, AND UPPER AND LOWER CASE LETTERS?! Then I've got the juice for you!
¡UPDATE! Now improved performance of random string request having a length greater than 23! Was a slight issue before where long strings might not always be number requested, if request was greater than 23. However, NO LONGER A PROBLEM! ¡ENJOY!
/* COPY && PASTE */
function epicRandomString(b){for(var a=(Math.random()*eval("1e"+~~(50*Math.random()+50))).toString(36).split(""),c=3;c<a.length;c++)c==~~(Math.random()*c)+1&&a[c].match(/[a-z]/)&&(a[c]=a[c].toUpperCase());a=a.join("");a=a.substr(~~(Math.random()*~~(a.length/3)),~~(Math.random()*(a.length-~~(a.length/3*2)+1))+~~(a.length/3*2));if(24>b)return b?a.substr(a,b):a;a=a.substr(a,b);if(a.length==b)return a;for(;a.length<b;)a+=epicRandomString();return a.substr(0,b)};
/* COPY && PASTE */
EASY TO USE!!!
var rand = epicRandomString();
/* OR IF YOU NEED A SET LENGTH! */
var rand = epicRandomString(10);
Tested
1 MILLION TIMES! and found
0! duplicates with
no set length, and only
14! duplicates with a
set length of 10!
No comments:
Post a Comment