Not only is this not safe, it doesn't even work.
mt_rand
accepts 2 parameters, the minimum value and the maximum value.
mt_rand('password', 15)
This converts 'password'
to int ( 0
), then returns a random number between 0
and 15
.
uniqid(mt_rand('password', 15), true)
Then a unique identifier is generated and a random number is added from the previous step to it: calculating something like this:
144ffb22886d58e1.82100749
This line is md5'd.
As you can see, this code is 100% useless. The original password is converted to 0
and lost forever, so all you do is hash random numbers, which is pointless. Now that you have your hash, there is no way to check it again. Since the password is converted, what the user enters does not matter.
So no, this code is not protected, do not use it.
Personally, I use the phpass library . It is safe and easy to use.
source share