DEV Community

PROTIK
PROTIK

Posted on

1

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)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay