ericek111

Password generator

Sep 17th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.29 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5.     <title>Random password generator</title>
  6.     <script type="text/javascript">
  7.         function generate() {
  8.             var pform = document.getElementById("passform")
  9.             var plen = pform.elements["plen"].value;
  10.             var ptype = pform.elements["passtype"].value;
  11.             var pstr = "";
  12.             var alph = ptype;
  13.             for(var i = 0; i < plen; i++) {
  14.                 pstr += alph.charAt(Math.floor(Math.random() * alph.length));
  15.             }
  16.             pform.elements["password"].value = pstr;
  17.         }
  18.     </script>
  19.     <style type="text/css">
  20.         body, html {
  21.             margin: 0;
  22.             padding: 0;
  23.             width: 100%;
  24.             height: 100%;
  25.             display: flex;
  26.             justify-content: center;
  27.             align-items: center;
  28.             font-family: Tahoma;
  29.             font-size: 13px
  30.         }
  31.         #container {
  32.             box-shadow: 0 0 20px rgba(50, 50, 50, 0.8);
  33.             min-width: 250px;
  34.         }
  35.         .options {
  36.             padding: 10px 20px;
  37.             background-color: #66ff99;
  38.         }
  39.         .result {
  40.             padding: 10px;
  41.             background-color: #ff6666;
  42.         }
  43.         .result input {
  44.             width: calc(100% - 10px);
  45.             padding: 5px ;
  46.             border: none;
  47.             text-align: center;
  48.         }
  49.         .options #genbut {
  50.             display: block;
  51.             margin: 0 auto;
  52.             margin-top: 10px;
  53.             background: #ff0000;
  54.             border: 1px solid #333;
  55.             padding: 5px 10px;
  56.             font-weight: bold;
  57.             cursor: pointer;
  58.             color: #fff;
  59.         }
  60.         .options #genbut:hover {
  61.             box-shadow: 0 0 10px #ff0000;
  62.         }
  63.         .options #passtype {
  64.             margin-top: 5px;
  65.         }
  66.         .title {
  67.             padding: 10px 20px;
  68.             background-color: #ffff66;
  69.             text-align: center;
  70.             font-size: 15px;
  71.         }
  72.         </style>
  73. </head>
  74. <body>
  75. <div id="container">
  76.     <form id="passform">
  77.         <div class="title"><b>Password Generator</b></div>
  78.         <div class="options">
  79.         <label>Length: </label><input type="number" name="plen" min="6" max="64" value="12" /><br />
  80.         <label>Type: </label>
  81.         <select id="passtype" name="passtype">
  82.             <option value="0123456789">Numbers only</option>
  83.             <option value="abcdefghijklmnopqrstuvwxyz">az</option>
  84.             <option value="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789">azAZ09</option>
  85.         </select><br />
  86.  
  87.         <input type="button" name="genbut" id="genbut" value="Generate!" onclick="generate()" />
  88.         </div>
  89.         <div class="result">
  90.             <input type="text" name="password" placeholder="Press Generate button" readonly />
  91.         </div>     
  92.  
  93.     </form>
  94. </div>
  95. </body>
  96. </html>
Add Comment
Please, Sign In to add comment