RSS

PHP Password Generator

Tue, Oct 14, 2008

PHP

This tutorial is going to show you how to make a password generator.

You might have a website where your users security is very important and you would prefer to set a password for them rather than them set their own. Well here is a very simple yet flexible method in which you can create completly random passwords.

The first thing we need to do is define all of our functions. In this script there are 3. $minimum for the minimum ammount of characters to be in the password. $maximum for the maximum ammount of characters. And $password for the password which has been created.

So we define these using this code:

$minimum=7;
$maximum=15;
$password="";

Next we have to select random characters which is done by the following bit of code…

for($i=0;$i
{
$number=rand(48,122);

if(($number > 97 && $number < 122))
{
$password.=chr($number);
}

else if(($number > 65 && $number < 90))
{
$password.=chr($number);
}

else if(($number >48 && $number < 57))
{
$password.=chr($number);
}

else if($number==95)
{
$password.=chr($number);
}

else
{
$i–;
}
}

Now that is the password created. Now we just have to show it. You do this using this code:

echo $password;

Fairly simple, just the randomising bit which can get complicated.

Rating: 6.0/10 (11 votes cast)
Share and Enjoy:
  • Digg
  • Google
  • Technorati
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Furl
  • Live
  • Reddit
  • Spurl

  • Subscribe
    • XML
    • Google Reader or Homepage
    • Add to My Yahoo!
    • Subscribe with Bloglines
    • Subscribe in NewsGator Online
    • BittyBrowser
    • Add to My AOL
    • Convert RSS to PDF
    • Subscribe in Rojo
    • Subscribe in FeedLounge
    • Subscribe with Pluck RSS reader
    • Solosub
    • MultiRSS
    • R|Mail
    • Rss fwd
    • Blogarithm
    • Eskobo
    • gritwire
    • BotABlog
    • Simpify!
    • Add to Technorati Favorites!
    • Add to netvibes
    • Add this site to your Protopage
    • Subscribe in NewsAlloy
    • Subscribe in myEarthlink
    • Add to your phone
    • Get RSS Buttons

, , ,



This post was written by:

admin - who has written 41 posts on Unreal Media.


Contact the author

2 Comments For This Post

  1. Commenter Says:

    Cool. Im going to use this on my site :)

    Rating: 0.0/5 (0 votes cast)
  2. Briefe Schreiben Says:

    Hi! Your Post “” is very interesting for me. Unfortunately my written English is not so good so I write in German: Dir, meinem liebsten, geh

    Rating: 0.0/5 (0 votes cast)

Leave a Reply