<?php
class SnowFlake
{
private static $lastTimestamp = 0;
private static $lastSequence = 0;
private static $sequenceMask = 4095;
private static $twepoch = 1508945092000;
static function randStr($length)
{
return substr(str_shuffle("abcdefghijkmnpqrstuvwxyzABCDEFGHIJKMNPQRSTUVWXYZ23456789"), 0, $length);
}
static function randNumStr($length)
{
$chars = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
);
$password = '';
while (strlen($password) < $length) {
$password .= $chars[rand(0, 9)];
}
retu
生成基于雪花算法的随机编号
最新推荐文章于 2025-05-28 17:43:09 发布