Skip to content

Instantly share code, notes, and snippets.

@wal-f
wal-f / generate new password bookmarklet.js
Last active August 29, 2015 14:22 — forked from seabre/random_password.js
Password generator bookmarklet. Can set length (default's 20) and whether to include special characters, per use. Option to regen if not happy with output. Ideal for use with password managers.
javascript:(function(){var%20c=['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','0','1','2','3','4','5','6','7','8','9'],l=prompt('Password%20length?',20),p;if(!l)return;if(isNaN(l=parseInt(l))||l<1){alert('Invalid%20length');return}if(confirm('Special%20characters?'))Array.prototype.push.apply(c,['!','@','#','$','%','^','&','*','(',')','-','_','=','+','[','{',']','}','\\','|',';',':',"'",'"',',','<','.','>','/','?','`','~']);do{p='';while(p.length<l)p+=c[Math.floor(Math.random()*c.length)]}while(prompt('Copy%20and%20OK,%20or%20cancel%20for%20new%20one',p)==null)})();