[ create a new paste ] login | about

Link: http://codepad.org/wIw8JEjW    [ raw code | output | fork ]

PHP, pasted on Aug 6:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?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 < 8; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass); //turn the array into a string
}

echo randomPassword();
?>


Output:
1
nuEE83hI


Create a new paste based on this one


Comments: