kapott icon

random_password_02.js

kapott | PRO | 01/04/19 11:32:06 AM UTC | 0 ⭐ | 275 👁️ | Never ⏰ | []
JavaScript |

570 B

|

None

|

0 👍

/

0 👎

/**
    Code golf: Password generator mk2
    Constraints: Password must be 16char, must contain 1 lowercase, 1 uppercase, 1 number - no special chars allowed
 
    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.
 
2019-01-04: 135 bytes (135chr)
*/
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

Comments