Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function randomPassword() {
- $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
- $pass = array(); //remember to declare $pass as an array
- $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
- for ($i = 0; $i < 12; $i++) {
- $n = rand(0, $alphaLength);
- $pass[] = $alphabet[$n];
- }
- return implode($pass); //turn the array into a string
- }
- $pass = randomPassword();
- $file = fopen("pass.txt", "w") or die("Unable to open file!");
- fwrite($file, $pass);
- fclose($file);
- echo $pass;
- ?>
Add Comment
Please, Sign In to add comment