Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function randomString(len, matrix='qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM_-.#@'){
- var ret='';
- for(var i=0;i<len;i++){
- ret+=matrix.charAt(Math.floor(Math.random()*matrix.length));
- }
- return ret;
- }
- /*
- EXAMPLE BEGINE
- */
- console.log(randomString(7));
- console.log(randomString(3));
- console.log(randomString(30));
- console.log(randomString(9), "1234567890");
- console.log(randomString(13), ",./;'[]-=\\|}{+_:\"?><");
- /*
- EXAMPLE END
- */
Add Comment
Please, Sign In to add comment