phpMySQL

Membuat ‘random generate password’

Berikut script untuk membuat password acak:

function genPass($len = 10) {
    $charPool = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
    $pass = array();
    $length = strlen($charPool) - 1;
    for ($i = 0; $i < $len; $i++) {
        $n = rand(0, $length);
        $pass[] = $charPool[$n];
    }
    return implode($pass);
}
echo genPass();

Leave a Reply

Your email address will not be published. Required fields are marked *