Advertisement
AceScottie

password.html

Jul 21st, 2018
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.08 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <style>
  4.     h3{color: red; display: inline;}
  5.     h5{color: red;}
  6.     </style>
  7. </head>
  8. <body>
  9. <input type="text" id="test"></input>
  10. <button onclick="checkStr()">Check</button>
  11.  
  12. <div id="count"></div>
  13. </body>
  14. </html>
  15.  
  16. <script>
  17. var alpha = ["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"];
  18. var ALPHA = ["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"];
  19. var numerical = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
  20. var symbols = [" ", "!", '"', "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "_", "`", "{", "|", "}", "~"];
  21.  
  22.  
  23. function checkStr(){
  24.     //HTML elements used
  25.     var pass = document.getElementById('test').value;
  26.     var out = document.getElementById('count');
  27.  
  28.    
  29.     //checks each letter of string to see if it matches anything in the 4 lists.
  30.     var inca = false;
  31.     var incA = false;
  32.     var incn = false;
  33.     var incs = false;
  34.     for (var i = 0; i < pass.length; i++) {
  35.         if(alpha.includes(pass[i])){inca = true;}
  36.         else if(ALPHA.includes(pass[i])){incA = true;}
  37.         else if(numerical.includes(pass[i])){incn = true;}
  38.         else if(symbols.includes(pass[i])){incs = true;}
  39.     }
  40.    
  41.    
  42.     // figures out how many characters can be used based on your character set. Also increases strength by 1 for each set used.
  43.     var set = 0;
  44.     var strength = 0;
  45.     if(inca){set += alpha.length; strength += 1;}
  46.     if(incA){set += ALPHA.length; strength += 1;}
  47.     if(incn){set += numerical.length; strength += 1;}
  48.     if(incs){set += symbols.length; strength += 1;}
  49.     var combos = Math.pow(set, pass.length);
  50.    
  51.     //section checks how many requirements are met and outputs as strength
  52.     var state = "weak";
  53.     if (strength == 1){state = "weak";}
  54.     else if(strength == 2){state = "Ok";}
  55.     else if(strength == 3){state = "good";}
  56.     else if(strength == 4){state = "strong";}
  57.     out.innerHTML = "your password is <h3>"+state+"</h3> with <h3>"+combos+"</h3> brute force tries";
  58. }
  59. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement