Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $alphabetUpper = array("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");
- $alphabetLower = array();
- foreach ($alphabetUpper as $letter) {
- array_push($alphabetLower, strtolower($letter));
- }
- $numbers = range(0, 9);
- $specialChars = array("!", "@", "#", "$", "%", "^", "&", "*", "_", "|", "/", "\\", ".");
- $characterSet = array_merge($alphabetUpper, $alphabetLower, $numbers, $specialChars);
- function generateRandomPassword() {
- global $characterSet;
- $count = (count($characterSet) - 1);
- $segment1 = ($characterSet[rand(0, $count)] . $characterSet[rand(0, $count)] . $characterSet[rand(0, $count)]);
- $segment2 = ($characterSet[rand(0, $count)] . $characterSet[rand(0, $count)] . $characterSet[rand(0, $count)]);
- $segment3 = ($characterSet[rand(0, $count)] . $characterSet[rand(0, $count)] . $characterSet[rand(0, $count)]);
- $segment4 = ($characterSet[rand(0, $count)] . $characterSet[rand(0, $count)] . $characterSet[rand(0, $count)]);
- return ($segment1 . "-" . $segment2 . "-" . $segment3 . "-" . $segment4);
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <!-- Created by Thomas Jones of TomTec Solutions (07/08/16) -->
- <title>4-Part Password Generator</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="jumbotron" style="text-align: center;">
- <h1><strong>4-Part Password Generator</strong></h1>
- <p>Your generated 4-Part Password:</p>
- <pre><?php echo generateRandomPassword(); ?></pre>
- <a href="passgen.php">Re-Generate</a>
- </div>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment