|
|
|
Unique random key
4
This php script provides a unique random key with 32 characters and can be used to avoid the system to pass some primary keys across the url, by example.




pimteam
zjakupec
Pushkartyagi
niprasnja
lzodan
mlcorak
bonikolic
mezestic1
rekapec
Kasimu
dannyboy
sundaramkumar
mattrmiller
all-battery
Pio
Cloudgen
i_kenneth
ASmith
mycodeofshailendra
ctiggerf

|
|
|
Btw if you want to make something like UNIQUE ID for members, it's much easier and smarter to just hash (md5) "$user:$pass" or some other unique field plus some other just to add some more bytes
Sasa Karanovic
www.MrdniSe.com
www.SasaKaranovic.com
I've got good news, and I've got bad news:
The universe is merely a figment of my imagination.
Now are you ready for the bad news?
// Keys are only valid on the day generated
$date = date('m-d-Y');
// We share a secret
$secret = 'secret_shared_between_client_and_server';
// I'll send you this salt in plaintext
$salt = rand();
return array($salt,md5($date.$secret.$salt));
}
// Can we match the passed key and salt using today's date and our
// shared secret?
return md5(date('m-d-Y').$secret.$salt) == $key;
}
// date adds keyspace size, rand adds unpredictability,
// salt precludes rainbow table attacks
global $system_salt;
return md5($system_salt.rand().date());
}
Say for ex. am passing a value from one page to another page and use the function to create a key. If I want to verify / check the created random is key is a correct one, how to do that.
Correct me if am wrong. Can you mention the use of this script as well. so that I can understand clearly.
Regards,
Kumar S
GuyFromChennai.com