Commit ef3726d4 by 杨昕

生成唯一编号

parent 7e84d396
Pipeline #13147 passed with stages
in 44 seconds
......@@ -297,6 +297,8 @@ function generateRandomNum( $len = 32, $md5 = true ) {
# Create random token at the specified length
for ( $i=0; $i<$len; $i++ )
$token .= $chars[ mt_rand(0, $numChars) ];
$time = microtime(true);
# Should token be run through md5?
if ( $md5 ) {
# Number of 32 char chunks
......@@ -305,8 +307,9 @@ function generateRandomNum( $len = 32, $md5 = true ) {
for ( $i=1; $i<=$chunks; $i++ )
$md5token .= md5( substr($token, $i * 32 - 32, 32) );
# Trim the token
$token = substr($md5token, 0, $len);
$token = md5($time.substr($md5token, 0, $len));
}
return $token;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment