Guest User

passwordgen 9 nov 2023

a guest
Nov 9th, 2023
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 18.52 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.    <head>
  4.       <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  5.       <link rel="icon" type="image/x-icon" href="key.png">
  6.       <style>
  7.          body {
  8.          text-align: left;
  9.          margin: 20px;
  10.          }
  11.          h1 {
  12.          color: #3498db;
  13.          }
  14.          h2 {
  15.          color: #7eb84b;
  16.          }
  17.          @media (min-width: 768px) {
  18.          body {
  19.          margin-right: 40%;
  20.          }
  21.          .slider-container {
  22.          margin: 20px;
  23.          }
  24.          }
  25.          @media (max-width: 767px) {
  26.          body {
  27.          margin: 5px;
  28.          }
  29.          .slider-container {
  30.          flex-direction: column;
  31.          }
  32.          button {
  33.          width: 100%;
  34.          }
  35.          .slider {
  36.          width: 100%;
  37.          }
  38.          }
  39.          pre {
  40.          color: #000000;
  41.          }
  42.          code {
  43.          color: #595959;
  44.          }
  45.          button {
  46.          background-color: #27ae60;
  47.          color: white;
  48.          padding: 10px 20px;
  49.          border: none;
  50.          cursor: pointer;
  51.          }
  52.          footer {
  53.          position: fixed;
  54.          bottom: 0;
  55.          left: 0;
  56.          width: 100%;
  57.          background-color: #111;
  58.          color: white;
  59.          text-align: left;
  60.          padding: 2px;
  61.          }
  62.          .answer {
  63.          padding-left: 15px;
  64.          padding: 10px;
  65.          }
  66.          .slider-container {
  67.          display: flex;
  68.          align-items: center;
  69.          margin: 20px;
  70.          }
  71.          .slider {
  72.          flex: 1;
  73.          }
  74.          .monospaced-input {
  75.          font-family: "Courier New", monospace;
  76.          }
  77.          #password {
  78.          font-size: 20px;
  79.          padding: 10px;
  80.          margin: 10px;
  81.          border: 1px solid #ccc;
  82.          }
  83.          .m {
  84.          margin: 10px;
  85.          }
  86.          #password-strength-bar {
  87.          height: 20px;
  88.          width: 100%;
  89.          margin: 10px 0;
  90.          background-color: red;
  91.          border-radius: 10px;
  92.          }
  93.       </style>
  94.    </head>
  95.    <body>
  96.       <h1>Password Generator</h1>
  97.       <div class="slider-container">
  98.          <label for="password-length">Password length: <span id="password-length">19</span></label>
  99.          <input type="range" min="12" max="31" value="19" class="slider" id="length-slider" />
  100.       </div>
  101.       <div>
  102.          <label for="lowercase">Include lowercase:</label>
  103.          <input type="checkbox" id="lowercase" checked />
  104.       </div>
  105.       <div>
  106.          <label for="uppercase">Include uppercase:</label>
  107.          <input type="checkbox" id="uppercase" checked />
  108.       </div>
  109.       <div>
  110.          <label for="numbers">Include numbers:</label>
  111.          <input type="checkbox" id="numbers" checked />
  112.       </div>
  113.       <div>
  114.          <label for="special-chars">Include special:</label>
  115.          <input type="checkbox" id="special-chars" checked />
  116.       </div>
  117.       <button onclick="generatePassword()">Generate password</button>
  118.       <input type="text" id="password" readonly value="your password" onclick="copyToClipboard()" class="monospaced-input" />
  119.       <div id="copiedText"></div>
  120. usable?:
  121. <p class="m" id="usable"></p>
  122. password strength:
  123. <p class="m" id="password-strength"></p>
  124. hash equivalent (do not use) comparasion against 128 bit:
  125. <p class="m" style="font-family: 'Courier New', monospace;" id="random-hex-string"></p>    
  126. <p class="m" style="font-family: 'Courier New', monospace;">f054bbd2f5ebab9cb5571000b2c50c02</p>      
  127.  
  128. <div id="password-strength-bar"></div>
  129.       <br>
  130.       <textarea id="passwordlist" readonly onclick="copyAndDownload()" class="monospaced-input" rows="10" cols="30">>your password list</textarea>
  131.       <div id="copiedList"></div>
  132.      
  133.       <br />
  134.       <br />
  135.       <br />
  136.       visualization of bit calculating in an average computer in 2 minutes
  137.               <details>
  138.             <summary>click to see picture</summary>
  139.       <img src="BITS_2023-11-09_13-13.png" style="width: 100%">
  140.       </details>
  141.      
  142.           <h2>Recommendations</h2>
  143.     <p>Creating strong passwords is essential for your online security. Follow these guidelines to help protect your accounts:</p>
  144.     <ul>
  145.         <li><strong>length:</strong> use passwords that are at least 12 characters long. longer passwords are more secure.</li>
  146.         <li><strong>complexity:</strong> include a mix of upper and lower case letters, numbers, and special characters (e.g., !, @, #, $, %).</li>
  147.         <li><strong>passphrases:</strong> consider using passphrases, which are longer combinations of words or phrases that are easy for you to remember but hard for others to guess. for example, "purpletiger$jump4joy!"</li>
  148.         <li><strong>avoid dictionary words:</strong> do not use easily guessable words found in dictionaries or common phrases.</li>
  149.         <li><strong>unique:</strong> create unique passwords for each account. do not reuse passwords across multiple sites.</li>
  150.         <li><strong>two-factor authentication (2fa):</strong> enable 2fa whenever possible to add an extra layer of security.</li>
  151.         <li><strong>password managers:</strong> use a reputable password manager to generate, store, and autofill complex and unique passwords.</li>
  152.         <li><strong>avoid personal information:</strong> do not use easily discoverable personal information like birthdates, names of family members, or common patterns.</li>
  153.         <li><strong>secure storage:</strong> store your passwords securely. avoid writing them down on easily accessible physical items.</li>
  154.     </ul>
  155.      
  156.       <h2>FAQ:</h2>
  157.       <b>why i can only choose between 12 and 31 length? </b><br>
  158.       <div class="answer">below 12 characters is not recommended at any level that isn't for fun, it will be just reckless to do so. the >31 limit is because they will be uncompatible with some crappy websites (see tiktok with 20 character limit). other solution could be not using trash websites like tiktok. if you want a really long password, <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">click here</a>
  159.       </div>
  160.       <br><br>
  161.       <b>why aren't there more options like extended ascii or unicode characters? </b><br>
  162.       <div class="answer">
  163.       same reason as before: they will be uncompatible with some crappy websites, so it's just stupid to include them
  164. </div>
  165.      
  166.       <br />
  167.       <br />
  168.     <div style="background-color: #cfcfcf; border: 2px solid #2980b9; padding: 10px;">
  169.         <h3>8 Nov 2023 Update</h3>
  170.         <p>- Added a password list that you can download and copy by clicking it.<br>
  171.         - Added favicon.<br>
  172.         - Corrected the news board and uppercased it on accident.<br>
  173.         - Added some more stuff.</p>
  174.        
  175.         <details>
  176.             <summary>click to see code</summary>
  177.             <pre><code>function copyAndDownload() {
  178.   const passwordListTextarea = document.getElementById("passwordlist");
  179.  
  180.   const textContent = passwordListTextarea.value;
  181.  
  182.   const blob = new Blob([textContent], { type: "text/plain" });
  183.  
  184.   const url = URL.createObjectURL(blob);
  185.  
  186.   const downloadLink = document.createElement("a");
  187.   downloadLink.href = url;
  188.   downloadLink.download = "password_list.txt";
  189.  
  190.   downloadLink.click();
  191.  
  192.   URL.revokeObjectURL(url);
  193. }
  194. </code></pre>
  195.         </details>
  196.         <hr>
  197.        
  198.         <p>Permalink: <a href="https://pastebin.com/4Wiq8CRS">https://pastebin.com/4Wiq8CRS</a></p>
  199.         <hr>
  200.  
  201.         <h3>5 Nov 2023 Update</h3>
  202.         <p>Fixed a bug in generatePassword() that made the password sometimes shorter than the user's input. Also changed getRandomInt() to:</p>
  203.        
  204.         <details>
  205.             <summary>click to see code</summary>
  206.             <pre><code>function getRandomInt(min, max) {
  207.   const cryptoObj = window.crypto || window.msCrypto;
  208.   const range = max - min + 1;
  209.   if (range <= 0) {
  210.    throw new Error('Invalid range');
  211.  }
  212.  
  213.  const maxMultiple = Math.floor(0xFFFFFFFF / range) * range;
  214.  
  215.  let randomValue;
  216.  do {
  217.    const array = new Uint32Array(1);
  218.    cryptoObj.getRandomValues(array);
  219.    randomValue = array[0];
  220.  } while (randomValue >= maxMultiple);
  221.  
  222.   const bucketSize = maxMultiple / range;
  223.   return min + Math.floor(randomValue / bucketSize);
  224. }
  225. </code></pre>
  226.         </details>
  227.  
  228.         <hr>
  229.  
  230.         <h3>4 Nov 2023 Update</h3>
  231.         <p>Added crypto randomness:</p>
  232.        
  233.         <details>
  234.             <summary>click to see code</summary>
  235.             <pre><code>let password = "";
  236.  
  237. for (let i = 0; i < length; i++) {
  238.  const randomIndex = getRandomInt(0, allChars.length);
  239.  password += allChars.charAt(randomIndex);
  240. }
  241.  
  242. function getRandomInt(min, max) {
  243.  const cryptoObj = window.crypto || window.msCrypto;
  244.  const array = new Uint32Array(1);
  245.  cryptoObj.getRandomValues(array);
  246.  return min + (array[0] / 0xFFFFFFFF) * (max - min + 1);
  247. }
  248. </code></pre>
  249.         </details>
  250.  
  251.         <hr>
  252.  
  253.         <p>Old version: <a href="https://pastebin.com/um2W0W8q">https://pastebin.com/um2W0W8q</a></p>
  254.  
  255.         <hr>
  256.  
  257.         <h3>3 Nov 2023</h3>
  258.         <p>Made under 10 minutes! (Using ChatGPT 3.5) Still adding stuff.</p>
  259.  
  260.         <p>Second ChatGPT-3.5 conversation: <a href="https://chat.openai.com/share/44f5d06b-f855-40bb-85fb-2ae02d1aa41b">https://chat.openai.com/share/44f5d06b-f855-40bb-85fb-2ae02d1aa41b</a></p>
  261.  
  262.         <p>Original ChatGPT-3.5 conversation: <a href="https://chat.openai.com/share/bf48570d-0cbd-4d54-a763-0ade7e0c574d">https://chat.openai.com/share/bf48570d-0cbd-4d54-a763-0ade7e0c574d</a></p>
  263.  
  264.         <hr>
  265.  
  266.         <div style="display: inline-block; text-align: center; font-family: Arial, sans-serif;">
  267.             <img src="key.webp" alt="key" style="width: 100%; max-width: 500px;">
  268.             <div style="background-color: darkgrey; color: white; padding: 5px 10px;">
  269.                AI generated cool art
  270.             </div>
  271.          </div>
  272.     </div>
  273.       <br>
  274.       <br>
  275.       <br>
  276.       <script>
  277.   function generateRandomHexString(bits) {
  278.     const bytes = Math.ceil(bits / 8);
  279.     const buffer = new Uint8Array(bytes);
  280.     crypto.getRandomValues(buffer);
  281.     const hexString = Array.from(buffer).map(byte => byte.toString(16).padStart(2, '0')).join('');
  282.     return hexString.substr(0, bytes * 2);
  283.   }
  284.          function copyToClipboard() {
  285.              const passwordField = document.getElementById("password");
  286.              passwordField.select();
  287.              document.execCommand("copy");
  288.              const copiedText = document.getElementById("copiedText");
  289.              copiedText.innerHTML = "Copied to clipboard!";
  290.          }
  291.          
  292.          function copyAndDownload() {
  293.              const passwordListTextarea = document.getElementById("passwordlist");
  294.          
  295.           const textContent = passwordListTextarea.value;
  296.          
  297.              const blob = new Blob([textContent], { type: "text/plain" });
  298.          
  299.              const url = URL.createObjectURL(blob);
  300.          
  301.              const downloadLink = document.createElement("a");
  302.              downloadLink.href = url;
  303.              downloadLink.download = "password_list.txt";
  304.          
  305.              downloadLink.click();
  306.          
  307.              URL.revokeObjectURL(url);
  308.              const copiedText = document.getElementById("copiedList");
  309.              copiedList.innerHTML = "Downloaded!";
  310.          }
  311.          
  312.          const lengthSlider = document.getElementById("length-slider");
  313.          const passwordLengthDisplay = document.getElementById("password-length");
  314.          const passwordInput = document.getElementById("password");
  315.          const passwordListInput = document.getElementById("passwordlist");
  316.          const passwordStrength = document.getElementById("password-strength");
  317.          const passwordStrengthBar = document.getElementById("password-strength-bar");
  318.          
  319.          const lowercaseChars = "abcdefghijklmnopqrstuvwxyz";
  320.          const uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  321.          const numberChars = "0123456789";
  322.          const specialChars = "!@#$%^&*()_+-=[]{}|;:'<>,.?/";
  323.          
  324.          lengthSlider.addEventListener("input", updatePassword);
  325.          document.getElementById("lowercase").addEventListener("change", updatePassword);
  326.          document.getElementById("uppercase").addEventListener("change", updatePassword);
  327.          document.getElementById("numbers").addEventListener("change", updatePassword);
  328.          document.getElementById("special-chars").addEventListener("change", updatePassword);
  329.          
  330.          function updatePassword() {
  331.              const length = parseInt(lengthSlider.value);
  332.              passwordLengthDisplay.textContent = length;
  333.              generatePassword();
  334.          }
  335.          
  336.          function generatePassword() {
  337.            
  338.        
  339.    
  340.    
  341.              const length = lengthSlider.value;
  342.              const useLowercase = document.getElementById("lowercase").checked;
  343.              const useUppercase = document.getElementById("uppercase").checked;
  344.              const useNumbers = document.getElementById("numbers").checked;
  345.              const useSpecialChars = document.getElementById("special-chars").checked;
  346.            
  347.              // space is the only character by default, which is also a character (that doesn't enter in the other categories)
  348.              const allChars = "" + (useLowercase ? "abcdefghijklmnopqrstuvwxyz" : "")+ (useUppercase ? "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : "") + (useNumbers ? "0123456789" : "") + (useSpecialChars ? "!@#$%^&*()_+-=[]{}|;:'<>,.?/" : "");
  349.          
  350.              let password = "";
  351.              while (password.length < length) {
  352.                 const randomIndex = getRandomInt(0, allChars.length);
  353.                 password += allChars.charAt(randomIndex);
  354.             }
  355.        
  356.             password = password.slice(0, length);
  357.        
  358.             passwordInput.value = password;
  359.             calculatePasswordStrength(password);
  360.            
  361.             const passwordList = [];
  362.        
  363.             for (let i = 0; i < 10; i++) {
  364.                 let password = "";
  365.                 while (password.length < length) {
  366.                   const randomIndex = getRandomInt(0, allChars.length);
  367.                   password += allChars.charAt(randomIndex);
  368.                 }
  369.                   passwordList.push(password);
  370.                   console.log(passwordList)
  371.             }
  372.             const htmlContent = passwordList.join("\n");
  373.        
  374.             passwordListInput.value = htmlContent;
  375.         }
  376.        
  377.         function getRandomInt(min, max) {
  378.             const cryptoObj = window.crypto || window.msCrypto;
  379.             const range = max - min + 1;
  380.             if (range <= 0) {
  381.                 throw new Error("Invalid range");
  382.             }
  383.        
  384.             const maxMultiple = Math.floor(0xffffffff / range) * range;
  385.        
  386.             let randomValue;
  387.             do {
  388.                 const array = new Uint32Array(1);
  389.                 cryptoObj.getRandomValues(array);
  390.                 randomValue = array[0];
  391.             } while (randomValue >= maxMultiple);
  392.          
  393.              const bucketSize = maxMultiple / range;
  394.              return min + Math.floor(randomValue / bucketSize);
  395.          }
  396.          
  397.          function calculatePasswordStrength(password) {
  398.              const minBits = 0;
  399.              const maxBits = 200;
  400.              const charsetSize = calculateCharsetSize();
  401.              const passwordBits = Math.log2(Math.pow(charsetSize, password.length));
  402.              passwordStrength.textContent = `${passwordBits.toFixed(2)} bits`;
  403.              updatePasswordStrengthBar(passwordBits, minBits, maxBits);
  404.              
  405.              
  406.              let usable = ""
  407.              let color = "red"
  408.              if (passwordBits < 60) {
  409.               usable = "NO! DO NOT USE THIS PASSWORD. THIS IS ONLY FOR DEMONSTRATIONAL PURPOSES"
  410.             } else if (passwordBits < 80) {
  411.               usable = "Maybe. It's crackable in a lifetime, but it will last at least some years. Better if it isn't in the hands of a powerful computer."
  412.               color = "#dbc72e"
  413.             } else if (passwordBits < 128) {
  414.               usable = "Yes! This password is absolutely secure. It will only fail if everyone in the world is trying to crack it."
  415.               color = "green"
  416.             } else {
  417.               usable = "Yes! Even if it's in the hands of many supercomputers!"
  418.               color = "#00470b"
  419.              
  420.             }
  421.            const use = document.getElementById('usable');
  422.            use.textContent = `${usable}`;
  423.            use.style.color = color;
  424.            const randomHexString = generateRandomHexString(passwordBits);
  425.            
  426.            const randomHexStringElement = document.getElementById('random-hex-string');
  427.            randomHexStringElement.textContent = `${randomHexString}`;
  428.  
  429.         }
  430.        
  431.         function calculateCharsetSize() {
  432.           const useLowercase = document.getElementById("lowercase").checked;
  433.             const useUppercase = document.getElementById("uppercase").checked;
  434.             const useNumbers = document.getElementById("numbers").checked;
  435.             const useSpecialChars = document.getElementById("special-chars").checked;
  436.        
  437.             let charsetSize = 0;
  438.             if (useLowercase) charsetSize += lowercaseChars.length;
  439.             if (useUppercase) charsetSize += uppercaseChars.length;
  440.             if (useNumbers) charsetSize += numberChars.length;
  441.             if (useSpecialChars) charsetSize += specialChars.length;
  442.        
  443.             return charsetSize;
  444.         }
  445.        
  446.         function updatePasswordStrengthBar(passwordBits, minBits, maxBits) {
  447.             const clampedBits = Math.min(Math.max(passwordBits, minBits), maxBits);
  448.             const strengthPercentage = ((clampedBits - minBits) / (maxBits - minBits)) * 100;
  449.             let strengthColor;
  450.        
  451.             if (strengthPercentage < 30) {
  452.                 strengthColor = "red";
  453.             } else if (strengthPercentage < 40) {
  454.                 strengthColor = "#dbc72e";
  455.             } else {
  456.                 strengthColor = "green";
  457.             }
  458.        
  459.             passwordStrengthBar.style.backgroundColor = strengthColor;
  460.             passwordStrengthBar.style.width = `${strengthPercentage}%`;
  461.         }
  462.        
  463.         updatePasswordStrengthBar(0, 0, 200);
  464.        
  465.         generatePassword();  
  466.      </script>
  467.    </body>
  468.    <footer>
  469.       <p>This work is in the public domain.</p>
  470.    </footer>
  471. </html>
Advertisement
Add Comment
Please, Sign In to add comment