首页 > 作文

PHP 生成 UUID 函数

更新时间:2023-04-07 23:49:58 阅读: 评论:0

generate name bad md5 uuid (version 3)

/** * generate name bad md5 uuid (version 3). * @example '7e57d004-2b97-0e7a-b45f-5387367791cd' */public function uuid(){    // fix for compatibility with 32bit architecture; s七夕节幽默搞笑的句子e锄字组词ed range restricted to 62bit    $ed = mt_rand(0, 2147483647) . '#' . mt_rand(0, 2147483647);    // hash the ed and convert to a byte array    $val = md5($ed, true);    $byte = array_values(unpack('c16', $val));    // extract fields from byte array    $tlo = ($byte[0] << 24) | ($byte[1] << 16) | ($byte[2] << 8) | $byte[3];    $tmi = ($byte[4] << 8) | $byte[5];    $thi = ($byte[6] << 8) | $byte[7];    $cslo = $byte[9];    $cshi = $byte[8] & 0x3f | (1 << 7);    // correct byte order for big edian architecture    if (pack('l', 0x6162797a) == pack('n', 0x6162797a)) {        $tlo = (($tlo & 0x000000ff) << 24) | (($tlo & 0x0000ff00) <<英皇芭蕾考级; 8)            | (($tlo & 0x00ff0000) >> 8) | (($tlo & 0xff000000) >> 24);        $tmi = (($tmi & 0x00ff) << 8) | (($tmi & 0xff00) >> 8);        $thi = (($thi & 0x00ff) << 8) | (($thi & 0xff00) >> 8);    }    // apply version numb秋天成熟的水果有哪些er    $thi &= 0x0fff;    $thi |= (3 << 12);    // cast to string    $uuid = sprintf(        '%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x',        $tlo,        $tmi,        $thi,        $cshi,        $cslo,        $byte[10],        $byte[11],        $byte[12],        $byte[13],        $byte[14],        $byte[15]    );    return $uuid;}

函数来源:fzaninotto/faker

地址:https://github.com/fzaninotto/fake美丽的同义词r

本文发布于:2023-04-07 23:49:33,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/13ef7c7c55c82a7c315fa972a74aaa1f.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:PHP 生成 UUID 函数.doc

本文 PDF 下载地址:PHP 生成 UUID 函数.pdf

标签:同义词   芭蕾   句子   英皇
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图