• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1494
  • Last Modified:

Random password 8-12 character unique alpha-numeric code

I want to generate random password 8 - 12 character unique alpha-numeric code. How do I proceed with correct random unique ?
0
Loganathan Natarajan
Asked:
Loganathan Natarajan
  • 3
1 Solution
 
striker46Commented:
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
 
striker46Commented:
Wrong variable name. Again:


$chars = 8;
$pwd = md5(time());
 
$pwd= substr($pwd, 0, $chars - 1);
 
echo $pwd;

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now