xyn Posted July 5, 2006 Share Posted July 5, 2006 Hi Guys.I've got my members area but I wanted to make the forgotten passwords more secure, So i thought i'd make a random password generator. So I can add this into the users password under MD5 and then e-mail them the new password.Is there any way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/13750-random-pass-gen/ Share on other sites More sharing options...
karthikeyan_coder Posted July 5, 2006 Share Posted July 5, 2006 yes you can... [code]$username = "user"; //current usrename ;$part1 = split($username,3); // Splitting first three chars for the username... Out put is an array ;$random_number = rand(2,78); // getting one random no between 2 to 78 ;$string = $part1[0] . $random_number; //making one new string...$newmd = md5($string); // MD5 encry of new string.$newpass = split($newmd,12); // spliting result with 12 chars$password = $newpass[0]; // use this $password to mail your user...[/code]Let me know how it is....Thank you,Karthi keyan Quote Link to comment https://forums.phpfreaks.com/topic/13750-random-pass-gen/#findComment-53424 Share on other sites More sharing options...
micah1701 Posted July 5, 2006 Share Posted July 5, 2006 this is what I do:[code]<?php //using pre-specified letters and numbers arrays to eliminate eL's and one's and Oh's and zero's $letters = array('a','b','c','d','e','f','g','h','j','k','m','n','p','q','r','s','t','u','v','x','y','z'); $numbers = array('2','3','4','5','6','7','8','9'); for ($i=0; $i<5; $i++) // Pick 5 random letters { $passwordArray[$i] = $letters[rand(0,count($letters))]; //$passwordArray[$i] = chr(rand(97,122)); } for ($i=5; $i<8; $i++) // Pick 3 random numbers { $passwordArray[$i] = $numbers[rand(0,count($numbers))]; //$passwordArray[$i] = chr(rand(48,57)); } shuffle($passwordArray); //(put the 8 charecters in random order) $sendPassword = implode("",$passwordArray); // end create passwordecho $sendPassword; // you can md5 this or e-mail it or encrypt it or whatever?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13750-random-pass-gen/#findComment-53426 Share on other sites More sharing options...
okphp Posted July 5, 2006 Share Posted July 5, 2006 Here is mine 8 characters of password[code]<?$random_password=md5(uniqid(rand())); $new_password=substr($random_password, 0, 8); // change here if you want more than 8 characters passwordecho $new_password;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13750-random-pass-gen/#findComment-53429 Share on other sites More sharing options...
Koobi Posted July 5, 2006 Share Posted July 5, 2006 i wouldn't say md5() is as secure anymore. hash collision can occur depending on the prefixes you use.why not try sha1() instead?maybe you could do something like this...off the top of my head:[code=php:0]<?php //assume $oldPass is the md5() value of his old password in your database $string = date('U') . $username . $oldPass; echo 'New password is: ' . sha1($string, true);?>[/code]You might want to use the algorithms the others have posted in this thread becuse mine is relatively simple but i would avoid md5()...but it's generally ok to use MD5 unless you know some REALLY nasty people who would REALLY want to get back at you for something :) Quote Link to comment https://forums.phpfreaks.com/topic/13750-random-pass-gen/#findComment-53433 Share on other sites More sharing options...
xyn Posted July 5, 2006 Author Share Posted July 5, 2006 Thanks guys!! Quote Link to comment https://forums.phpfreaks.com/topic/13750-random-pass-gen/#findComment-53462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.