Solved

Random password 8-12 character unique alpha-numeric code

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
The viewer will learn how to count occurrences of each item in an array.

749 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