stuppid_bot

Password Generator

Aug 29th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.74 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8">
  5.         <title>Password Generator</title>
  6.         <style>
  7.             body{margin:0;padding:10px;font:small/normal arial,sans-serif;}
  8.             input,textarea,select,button{font-family:inherit;margin:0;}
  9.             textarea{display:block;resize:none;overflow:auto;}
  10.             input[type="text"],textarea,select{padding:2px 4px;border:solid 1px #bebebe;}
  11.             .label{float:left;width:180px;font-weight:bold;text-align:right;}
  12.             .field{margin-left:190px;width:400px;}
  13.             .label,.field{line-height:30px;}
  14.             .field input[type="text"],textarea{width:96%;}
  15.         </style>
  16.         <script type="text/javascript">
  17.             function randChars(length, chars) {
  18.                 length = length || 6;
  19.                 chars = chars || 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890';
  20.                 var ret = '';
  21.                 while (ret.length < length) ret += chars.charAt(Math.random() * chars.length);
  22.                return ret;
  23.            }
  24.  
  25.            onload = function () {
  26.                var frm = document.getElementById('form1');
  27.                frm.onsubmit = function (e) {
  28.                    e.preventDefault();
  29.                    var passwords = [];
  30.                    for (var i = 0; i < 10; ++i) passwords.push( randChars(this.length.value, this.chars.value) );
  31.                    console.log(passwords);
  32.                    this.result.value = passwords.join('\n');
  33.                };
  34.            };
  35.        </script>
  36.     </head>
  37.     <body>
  38.         <h1>Password Generator</h1>
  39.         <form action="#" id="form1">
  40.             <div class="label">
  41.                 <label for="length">Password length</label>
  42.             </div>
  43.             <div class="field">
  44.                 <input id="length" name="length" onchange="this.value=parseInt(this.value)" value="10" size="2">
  45.             </div>
  46.             <div class="label">
  47.                 <label for="chars">Used chars</label>
  48.             </div>
  49.             <div class="field">
  50.                 <input type="text" id="chars" name="chars" value="QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890">
  51.             </div>
  52.             <div class="field">
  53.                 <input type="checkbox" id="set2" checked onchange="this.form.chars.value = this.form.chars.value.replace(/[a-z]/g, ''); if (this.checked) this.form.chars.value += 'qwertyuiopasdfghjklzxcvbnm';">
  54.                 <label for="set2">lower latin</label>
  55.             </div>
  56.             <div class="field">
  57.                 <input type="checkbox" id="set1" checked onchange="this.form.chars.value = this.form.chars.value.replace(/[A-Z]/g, ''); if (this.checked) this.form.chars.value += 'QWERTYUIOPASDFGHJKLZXCVBNM';">
  58.                 <label for="set1">upper latin</label>
  59.             </div>
  60.             <div class="field">
  61.                 <input type="checkbox" id="set3" checked onchange="this.form.chars.value = this.form.chars.value.replace(/\d/g, ''); if (this.checked) this.form.chars.value += '1234567890';">
  62.                 <label for="set3">digits</label>
  63.             </div>
  64.             <div class="field">
  65.                 <input type="checkbox" id="set4" onchange="this.form.chars.value = this.form.chars.value.replace(/[\x22-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]/g, ''); if (this.checked) this.form.chars.value += '\x22#$%&\x27()*+,-./:;<=>?@[\]^_`{|}~';">
  66.                 <label for="set4">delims</label>
  67.             </div>
  68.             <div class="field">
  69.                 <textarea name="result" rows="10" placeholder="Result"></textarea>
  70.             </div>
  71.             <div class="field">
  72.                 <button>Generate</button>
  73.             </div>
  74.         </form>
  75.     </body>
  76. </html>
Add Comment
Please, Sign In to add comment