PHP 生成UUID

来源:互联网 发布:linux设置待机时间 编辑:程序博客网 时间:2024/06/03 21:07
function zstr_uuid($namespace = '', $isSeparator = false, $isBrace = false) {    $guid = '';    $uid = uniqid("", true);    $data = $namespace;    $data .= $_SERVER['REQUEST_TIME'];    $data .= $_SERVER['HTTP_USER_AGENT'];    $data .= $_SERVER['LOCAL_ADDR'];    $data .= $_SERVER['LOCAL_PORT'];    $data .= $_SERVER['REMOTE_ADDR'];    $data .= $_SERVER['REMOTE_PORT'];    $hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));    $guid = $hash;    if ($isSeparator == true) {        $guid = substr($hash,  0,  8) .                '-' .                substr($hash,  8,  4) .                '-' .                substr($hash, 12,  4) .                '-' .                substr($hash, 16,  4) .                '-' .                substr($hash, 20, 12);    }    if($isBrace) {        $guid = '{' . $guid . '}';    }    return $guid;}
0 0
原创粉丝点击