1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Password Generator</title>
<style type="text/css">
body, html {
height:100%;
width:100%;
overflow:hidden;
}
body{
background-color: #8FB480;
color: #025D02;}
#cont {
width:450px;
margin:20px auto;
border: solid 2px #194308;
height:auto;
overflow:hidden;
}
.label {width : 150px;
float:left;
padding:5px 0 15px 15px;
}
.label, h3 { font-family:verdana;
}
.field {
width: 100%;
background-color: #9EEE91 ;
padding : 5px 0;
float:left;
}
#lon {
width:30px;
text-align:right;
}
#res {
width:250px;
font-family:consolas,dina,arial ;
font-size:15px;
text-align:center;
letter-spacing: 2px;}
.last,h3 {text-align:center;}
</style>
<script type="text/javascript">
//<![CDATA[
/******************************
* SpaceFrog 03.05.2010 *
* generateur de mots de passe *
*******************************/
var chars=new Array( "abcdefghijklmnopqrstuvwxyz".split(''),"abcdefghijklmnopqrstuvwxyz".toUpperCase().split(''),"0123456789".split(''),"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".split(''));
function generate(){
var level=+document.getElementById('niveau').value
var long=+document.getElementById('lon').value
if(long<level){alert('La longueur doit être au moins égale au niveau.');
return false;}
var rep=new Array();
myrand=new Date().getMilliseconds();
while(level>1){
templong=Math.ceil(Math.random(myrand)*(long-(--level))) ;
rep.push(templong);
long=long-templong;
}
rep.push(long)
var password=new Array();
var i=-1;
while(rep[++i]){
BaseL=chars[i].length
j=-1;
while((j++<rep[i]-1) && (password.push (chars[i][Math.floor(Math.random(Math.pow(new Date().getMilliseconds(),3))*BaseL)]))){}
}
document.getElementById('res').value=password.sort(sortRand).reverse().sort(sortRand).sort(sortRand).reverse().join('')
}
function sortRand(){return (Math.round(Math.random(myrand))-0.5); }
//]]>
</script>
</head>
<body>
<div id="cont">
<div class="field"><h3>SpaceFrog's password generator</h3></div>
<div class="field"><span class="label">Niveau :</span><select id="niveau">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select></div>
<div class="field"><span class="label">Longueur :</span><input type='text' id='lon' value='6' maxLength='2'/></div>
<div class="field"><span class="label">Mot de passe:</span><input type='text' id='res' value='' readonly="readonly" /></div>
<div class="last field"><input type="button" onclick="generate()" value = "generation" /></div>
</div>
</body>
</html> |
Partager