[eluser]the_unforgiven[/eluser]
Hi all,
Building an application and need to build a simple yet secure "forgot password" module
Basically i want it show a input field for their email address which will send them a sha1 password in plan english:
sha1 = hdf748yudf84hdr6394h for example would translate to password in the email that gets sent to the customer.
I just wondered what is the best way to do this and can someone show me examples so i know I'm on the right tracks.
I did find this helper
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('get_random_password'))
{
/**
* Generate a random password.
*
* get_random_password() will return a random password with length 6-8 of lowercase letters only.
*
* @access public
* @param $chars_min the minimum length of password (optional, default 6)
* @param $chars_max the maximum length of password (optional, default 8)
* @param $use_upper_case boolean use upper case for letters, means stronger password (optional, default false)
* @param $include_numbers boolean include numbers, means stronger password (optional, default false)
* @param $include_special_chars include special characters, means stronger password (optional, default false)
*
* @return string containing a random password
*/
function get_random_password($chars_min=6, $chars_max=8, $use_upper_case=false, $include_numbers=false, $include_special_chars=false)
{
$length = rand($chars_min, $chars_max);
$selection = 'aeuoyibcdfghjklmnpqrstvwxz';
if($include_numbers) {
$selection .= "1234567890";
}
if($include_special_chars) {
$selection .= "!@\"#$%&[]{}?|";
}
$password = "";
for($i=0; $i<$length; $i++) {
$current_letter = $use_upper_case ? (rand(0,1) ? strtoupper($selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))];
$password .= $current_letter;
}
return $password;
}
}
But not sure if its what i need, please help!?