Password Generator PHP Snippet

Password Generator PHP SnippetGet stuck attempting to select a brand new watchword every time you signup to a brand new service or web site. the majority do use constant watchword on each web site that they’re going to however this could be dangerous if one site gets hacked then your watchword can be used on all the sites you often use.

Therefore for best security reason you must use a unique watchword for various websites and there area unit several watchword management tools out there that may assist you bear in mind all of your passwords.

So if you’re having to concoct new passwords every time you check in to a web site you may run out of concepts of what to place and begin making simply something. however some websites have watchword strength needs, like it’s to own a minimum of one range, or one graphic symbol.

Password Strength

The below Password Generator PHP Snippet can generate a watchword for you and you’ll be able to customize it to an explicit level of watchword strength of Password Generator PHP Snippet.

  • If the strength is quite one then capitals area unit enclosed.
  • If the strength is quite two then capital vowels area unit enclosed.
  • If the strength is quite four then numbers area unit enclosed.
  • Finally if the strength is quite eight then special characters area unit enclosed.

I notice that a watchword strength of additional then four is nice enough for many websites.

<?php
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength >= 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength >= 2) {
$vowels .= "AEUY";
}
if ($strength >= 4) {
$consonants .= '23456789';
}
if ($strength >= 8 ) {
$vowels .= '@#$%';
}

$password = '';
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password; }
?>

Masum Billah has written 326 articles

Hi I am Md. Masum Billah Contributor of this website. I always like to share various things with other. In this website I am sharing web design related tips and tricks, necessary web development tools, source codes for beginner and advance web developer. You may join with us to help other who want to learn web design and development. Thank you for stay with.

Recommended Articles

One thought on “Password Generator PHP Snippet

  1. Haritha says:

    This blog is really informative. I gained more knowledge by reading your post. Thanks for providing us the useful information with us. Your blog is really helpful for me in attaining my knowledge in a right way.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>