If you forget your password, click "forgot password", and then you will receive a link to change the password. There will always be a long and messy string in the connection. If a duplicate string is displayed, wouldn't someone else's password be reset?
Therefore, generating unique numbers is important to website security.
Currently, PHP can generate unique numbers using hash values, random numbers, time, and other methods. below is the unique number I tested. I personally recommend guid.
Method 1:
<?PHP$ Str=Uniqid(Mt_rand(), 1);Echo'Sha1 :',Sha1($ Str);Echo'<Br>';Echo'Md5 :',MD5($ Str);?>
Use the uniqid function and the mt_rand random function. Finally, use the hash value to obtain the final unique value.
However, during the test, it is found that the uniqueness of the random number is somewhat the same, and there are about 11 Identical digits (but there is no problem)
Method 2: guid
<? PHP Echo Sprintf('% 04x % 04x-% 04x-% 04x-% 04x-% 04x % 04x % 04x ',Mt_rand(0, 65535 ),Mt_rand(0, 65535 ),Mt_rand(0, 65535 ),Mt_rand(16384,204 79 ),Mt_rand(51, 32768,491 ),Mt_rand(0, 65535 ),Mt_rand(0, 65535 ),Mt_rand(0, 65535))); Echo "<Br>" ; Echo Sprintf ('% 04x % 04x-% 04x-% 04x-% 04x-% 04x % 04x % 04x ', Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (16384,204 79 ), Mt_rand (51, 32768,491 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535) )); Echo "<Br>" ; Echo Sprintf ('% 04x % 04x-% 04x-% 04x-% 04x-% 04x % 04x % 04x ', Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (16384,204 79 ), Mt_rand (51, 32768,491 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535) )); Echo "<Br>" ; Echo Sprintf ('% 04x % 04x-% 04x-% 04x-% 04x-% 04x % 04x % 04x ', Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (16384,204 79 ), Mt_rand (51, 32768,491 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535 ), Mt_rand (0, 65535) )); ?>
introduction of UUID can be referred to: http://www.cnblogs.com/ghj1976/archive/2011/09/21/2184029.html