gpt4 book ai didi

php - PHP uniqid()源码相关问题

转载 作者:太空宇宙 更新时间:2023-11-04 08:28:40 25 4
gpt4 key购买 nike

<分区>

在 PHP 源代码函数 uniqid() 中有以下 C 代码:(我删除了一些类型以缩短它)

//...
struct timeval tv;
gettimeofday(&tv, NULL);
int sec = (int) tv.tv_sec;
int usec = (int) (tv.tv_usec % 0x100000);

// The max value usec can have is 0xF423F,
// so we use only five hex digits for usecs.
printf("%08x%05x", sec, usec);
//...

如果我们把批评放在一边,他们会尝试生成 64 位时间戳。

0xF423F 可能是 CLOCKS_PER_SEC - 1(CLOCKS_PER_SEC 是十进制的 1000000),

但是这个 0x100000 是从哪里来的,使用模而不是按位与的原因是什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com