Solved

Random password 8-12 character unique alpha-numeric code

Posted on 2009-04-05
4
1,434 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

705 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