?
Solved

Random password 8-12 character unique alpha-numeric code

Posted on 2009-04-05
4
Medium Priority
?
1,465 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 5

Accepted Solution

by:
striker46 earned 1000 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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Suggested Courses

770 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