Home > JavaScript > JavaScript Password Generator

JavaScript Password Generator

A very flexible and powerful password generator script written in JavaScript. With this password generator, you will not be bother or confuse to choose/select a strong and secure passwords for your important accounts.

Platform

This script can be run well using Mozilla Firefox (any version), Internet Explorer (any version), Opera and Fast Browser.

Preview

First character can be:
A Number
An lowercase letter
An uppercase letter
Other

The following characters can be:
A Number
An lowercase letter
An uppercase letter
Other

Password length:
Extra password characters:



Generated password:

Source Code


[html]<html>
<head>
<title>Javascript Password Generator</title>
<script language="JavaScript">
// By : Isusx Programming Corner
// URL :http://isusx.com

function gen_numb(min, max){
return (Math.floor(Math.random() * (max - min)) + min);
}

function gen_chr(num, lwr, upr, oth, ext){
var num_chr = "0123456789";
var lwr_chr = "abcdefghijklmnopqrstuvwxyz";
var upr_chr = lwr_chr.toUpperCase();
var oth_chr = "`~!@#$%^&*()-_=+[{]}\\|;:’\",<.>/? ";
var sel_chr = ext;

if(num == true)
sel_chr += num_chr;
if(lwr == true)
sel_chr += lwr_chr;
if(upr == true)
sel_chr += upr_chr;
if(oth == true)
sel_chr += oth_chr;
return sel_chr.charAt(gen_numb(0, sel_chr.length));
}

function gen_pass(len, ext, bgn_num, bgn_lwr, bgn_upr, bgn_oth,
flw_num, flw_lwr, flw_upr, flw_oth){
var res = "";

if(len > 0){
res += gen_chr(bgn_num, bgn_lwr, bgn_upr, bgn_oth, ext);
for(var i=1;i<len;i++)
res += gen_chr(flw_num, flw_lwr, flw_upr, flw_oth, ext);
return res;
}
}

function process(){
pass.value = gen_pass(
len.value,
ext.value,
bgn_num.checked,
bgn_lwr.checked,
bgn_upr.checked,
bgn_oth.checked,
flw_num.checked,
flw_lwr.checked,
flw_upr.checked,
flw_oth.checked
);
}
</script>
</head>
<body>
First character can be:
<input type="checkbox" id="bgn_num" checked>A Number
<input type="checkbox" id="bgn_lwr" checked>An lowercase letter
<input type="checkbox" id="bgn_upr" checked>An uppercase letter
<input type="checkbox" id="bgn_oth" checked>Other

The following characters can be:
<input type="checkbox" id="flw_num" checked>A Number
<input type="checkbox" id="flw_lwr" checked>An lowercase letter
<input type="checkbox" id="flw_upr" checked>An uppercase letter
<input type="checkbox" id="flw_oth" checked>Other

Password length: <input id="len" value="10" style="width:100">
Extra password characters: <input id="ext" style="width:200">

<input type="button" value="Generate" onclick="process()">

Generated password: <input id="pass" style="width:200">
</body>
</html>[/html]

Copyright Note

This script is free to use and can be modified as you wish.

Related Links

About Password
Javascript Source
About HTML element
About JavaScript

If you like this code/script, perhaps you would kindly treat me a drink. Any number is welcome. Thanks :)

Related Article

  1. XXX
    October 28th, 2008 at 16:37 | #1

    Telling you the truth, I like your password generator so much. From now on, I just need to open this page when I want to choose a random password. Well done

  1. No trackbacks yet.