Solved

Random password 8-12 character unique alpha-numeric code

Posted on 2009-04-05
4
1,440 Views
Last Modified: 2013-12-12
I want to generate random password 8 - 12 character unique alpha-numeric code. How do I proceed with correct random unique ?
0
Comment
Question by:Loganathan Natarajan
  • 3
4 Comments
 
LVL 5

Accepted Solution

by:
striker46 earned 250 total points
ID: 24075008
This is just a simple idea I've seen used in some sites.

Gets current timestamp, md5's it and gets the number of characters you desire from the beginning of the resulting string.

There are better ways to achieve the results but this one is fairly good and simple. Chances that a unique password is generated twice are extremely low because MD5 is always completely different for each timestamp.

$chars = 8;

$pwd = md5(time());
 

$rest = substr($pwd, 0, $chars - 1);
 

echo $pwd;

Open in new window

0
 
LVL 5

Expert Comment

by:striker46
ID: 24075010
Wrong variable name. Again:


$chars = 8;

$pwd = md5(time());

 

$pwd= substr($pwd, 0, $chars - 1);

 

echo $pwd;

Open in new window

0
 
LVL 36

Author Closing Comment

by:Loganathan Natarajan
ID: 31566918
thanks
0
 
LVL 5

Expert Comment

by:striker46
ID: 24137979
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now