
10-09-07, 01:10 PM
|
|
Member
|
|
Join Date: Sep 2007
Posts: 58
|
|
Random password generator
There are many huge,complex password generator scripts but I have created a simple and small one.
Quote:
|
echo substr(md5(rand()),0,8);
|
From this you can generate random passwords. Just change the red number to change the length of the password.
However this has two small limitations:
* Password length cannot be greater than 32 characters
* Though it will be alpha-numeric, the characters will not go beyond 'f' , since they are hex codes.
These limitations doesn't bother in normal cases.
|

10-09-07, 04:53 PM
|
|
Senior Member
|
|
Join Date: Jan 2007
Location: Dorset
Posts: 1,119
|
|
why not use timestamp?
|

10-09-07, 05:11 PM
|
|
Member
|
|
Join Date: Sep 2007
Posts: 58
|
|
Quote:
Originally Posted by jon123
why not use timestamp?
|
Once i thought of timestamp, but I thought that rand() will be better because suppose you have a very busy site, and for two users are trying to create random password if this happens within a difference of 1 sec then both will get same password.
You may think of another case where the password is not generated by humans, suppose a script is working and is allotting random password to 1000 different thing(may be users). Now since a script will run very fast hundreds of generated password will be same as those will be generated in a single second.
This problem may be minimized by using micro-second stamp, but rand() will make it foolproof.
|

10-09-07, 06:50 PM
|
|
Senior Member
|
|
Join Date: Jan 2007
Location: Dorset
Posts: 1,119
|
|
That is a fair point and I suppose that could happen.
TBH I have never used a script that generates many passwords at once, only lost password scripts and the timestamp option i prefer to use. I also don't rely on just password authentication.
I do however create random ids using rand() on one of my sites, but also check the output via a function to make sure that id hasn't been used previously.
|

11-09-07, 09:24 AM
|
 |
Senior Member
|
|
Join Date: Apr 2006
Location: Norway
Posts: 1,788
|
|
I realize need of password manager, earlier I used a password manager software but forgot the master password and lost the key file for all my passwords.  SBh can that script add the word of choice that you wish to include.?
|

11-09-07, 10:11 AM
|
|
Member
|
|
Join Date: Sep 2007
Posts: 58
|
|
Quote:
Originally Posted by paul
I realize need of password manager, earlier I used a password manager software but forgot the master password and lost the key file for all my passwords.  SBh can that script add the word of choice that you wish to include.?
|
Sorry, I don't understand what are you trying to mean by 'word of choice'. This script is a very simple form of password generator. It will only create random alpha-numeric passwords. This is just the basic idea about it, of course you can modify to add more features.
|

11-09-07, 10:27 AM
|
 |
Senior Member
|
|
Join Date: Apr 2006
Location: Norway
Posts: 1,788
|
|
Quote:
Originally Posted by SBh
Sorry, I don't understand what are you trying to mean by 'word of choice'. This script is a very simple form of password generator. It will only create random alpha-numeric passwords. This is just the basic idea about it, of course you can modify to add more features.
|
Actually I mean can I modify any password which are generated randomly?
|

11-09-07, 03:34 PM
|
 |
Got root?
|
|
Join Date: Aug 2007
Location: England, UK.
Posts: 1,340
|
|
It would be good having a password generator showing the MD5 hash and the password being displayed. MD5 is secure though so nothing like that could ever be evolved. It would be good if it could except the security vulnrability's.
|

12-09-07, 10:40 AM
|
 |
Senior Member
|
|
Join Date: Apr 2006
Location: Norway
Posts: 1,788
|
|
Quote:
Originally Posted by Dan
It would be good having a password generator showing the MD5 hash and the password being displayed. MD5 is secure though so nothing like that could ever be evolved. It would be good if it could except the security vulnrability's.
|
Well, I checked with Nuclear Password Storage Pocket PC Edition, they use the combination of MD5, Base64, and DES hashes and Cipher, free to download. I may try to use this one.
|

12-09-07, 05:58 PM
|
|
Member
|
|
Join Date: Sep 2007
Posts: 58
|
|
Another function
Code:
function generateCode($characters,$special_char=false) {
$possible = '1234567890abcdefghijklmnopqrstuvwxyz';
if($special_char)
$possible .= '!@#$%^&*()_+-=[]{};\':",./\<>?|`~';
$code = '';
$i = 0;
while ($i < $characters) {
$code1 = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if(rand()%2==0)
$code1= strtoupper($code1);
$code .=$code1;
$i++;
}
return $code;
}
This function will generate alpha-numeric + special character (optional) + upper & lower characters mixed passwords of any desired length.
Suppose to get a 8 character alpha numeric password, call
to get 10 character alpha-numeric with special character password call,
Code:
generateCode(10,true);
I created this code while i was creating random characters for a captcha image.
Last edited by SBh; 12-09-07 at 06:01 PM.
|

13-09-07, 10:33 AM
|
 |
Senior Member
|
|
Join Date: Apr 2006
Location: Norway
Posts: 1,788
|
|
Quote:
Originally Posted by SBh
Code:
function generateCode($characters,$special_char=false) {
$possible = '1234567890abcdefghijklmnopqrstuvwxyz';
if($special_char)
$possible .= '!@#$%^&*()_+-=[]{};\':",./\<>?|`~';
$code = '';
$i = 0;
while ($i < $characters) {
$code1 = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if(rand()%2==0)
$code1= strtoupper($code1);
$code .=$code1;
$i++;
}
return $code;
}
This function will generate alpha-numeric + special character (optional) + upper & lower characters mixed passwords of any desired length.
Suppose to get a 8 character alpha numeric password, call
to get 10 character alpha-numeric with special character password call,
Code:
generateCode(10,true);
I created this code while i was creating random characters for a captcha image.
|
Thanks a lot for these addition.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 12:24 PM.
Powered by vBulletin® Version 3.8.1 Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Copyright 2001-2010 Web Hosting UK. All rights reserved. Web Hosting UK Forum
|
Site Map
Knowledgebase Articles
Support Tutorials
|