DEV Community

PROTIK
PROTIK

Posted on

How to create Random Password Generator using PHP?

This can generate random password.

<?php
function randomPassword() {
    $alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $pass = array();
    $alphaLength = strlen($alphabet) - 1;
    for ($i = 0; $i < 26; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass);
}

echo randomPassword();
?>

But I want to save this password…

Top comments (0)