kapott

random_password_02.js

Jan 4th, 2019
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.     Code golf: Password generator mk2
  3.     Constraints: Password must be 16char, must contain 1 lowercase, 1 uppercase, 1 number - no special chars allowed
  4.  
  5.     I chose to brute-force a valid string out of pseudo-randomly generated strings; you can actually make it generate safer passwords by adjusting the range of charcodes it accepts, and adjusting the "pass"-criteria regex to require special chars.
  6.  
  7. 2019-01-04: 135 bytes (135chr)
  8. */
  9. do{for(i=17,q="";i>q.length;q+=String.fromCharCode(~~(Math.random()*74)+48));}while(!/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{16,}$/g.test(q))q
Add Comment
Please, Sign In to add comment