March 15, 2011

Generate Random Password from Bookmark

by blackbird

Ever need to quickly generate a random password? This code snipit will generate a 12 character password from a set of lowercase/uppercase/numbers.

You may either drag this Random Password link to your bookmark toolbar, or you can modify and extend the code below and create your own bookmark. Click the bookmark, and simply copy your password.

[code lang=”js”]javascript:(function(length){ranges=[[‘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]];code=”;for(i=0;i<length;i++){rkey=Math.floor(Math.random()*ranges.length);vkey=Math.floor(Math.random()*ranges[rkey].length);code+=ranges[rkey][vkey];}alert(code);clipboardData.setData(‘text’,code);})(12)[/code]