当前位置:网站首页>PHP生成唯一字符串
PHP生成唯一字符串
2020-11-08 16:17:00 【归来依旧少年】
php唯一串生成方式 uniqid ......
- 高并发32位唯一字符串;
- 可变唯一字符串;
- 订单号唯一串;
- 低频13位唯一串;
生成初始密码
$salt = substr(uniqid(rand()),-6);
$key = 'xx.xxx.com';
$pwd = md5(md5('123456').$salt.$key);
生成唯一id的几种方法
uniqid(); 13位字符串
uniqid('',true); 23位字符串
md5(uniqid(mt_rand(1,10000)));32位字符串
md5(uniqid(md5(microtime(true)),true)); 32位字符串
md5( uniqid( md5(microtime(true)),true ) . mt_rand(1,10000) );32位字符串
session_create_id()
//创建24位唯一值 14+6+4 20140507115523 123456 1234
date('YmdHis').substr(microtime(),2,6).mt_rand(1000,9999);
-
- uniqid() 13位字符串
$units = array();
for ($i = 0; $i < 3; $i++) {
$units[] = uniqid();
}
var_export($units);
array (
0 => '5fa799bee9f7e',
1 => '5fa799bee9f95',
2 => '5fa799bee9f96',
)
-
- uniqid() 23位字符串
$units = array();
for ($i = 0; $i < 3; $i++) {
$units[] = uniqid('', true);
}
var_export($units);
array (
0 => '5fa79a8371e2b9.16693379',
1 => '5fa79a8371e573.86696425',
2 => '5fa79a8371e5a8.44085231',
)
-
- uniqid() 32位字符串
$units = array();
for ($i = 0; $i < 3; $i++) {
$units[] = md5(uniqid(mt_rand(), true));
// $units[] = md5(uniqid(md5(microtime(true)),true))
}
var_export($units);
array (
0 => '56d06914ee44c0f568be745edf1410de',
1 => '914a38fe5a2b3124bc42593b39c12a22',
2 => 'fa4853979a3e6d19748c9b354f034d49',
)
参考链接
版权声明
本文为[归来依旧少年]所创,转载请带上原文链接,感谢
https://my.oschina.net/wangyaobeijing/blog/4708263
边栏推荐
- rabbitmq(一)-基础入门
- 关于adb连接手机offline的问题解决
- 华为在5G手机市场占据绝对优势,市调机构对小米的市占出现分歧
- Travel notes of Suzhou
- 数据库连接报错之IO异常(The Network Adapter could not establish the connection)
- 区块链周报:数字货币发展写入十四五规划;拜登邀请MIT数字货币计划高级顾问加入总统过渡团队;委内瑞拉推出国营加密交易所
- AI weekly: employees are allowed to voluntarily reduce salary; company response: employees are happy and satisfied; tiger tooth HR takes employees out of the company; Sweden forbids Huawei ZTE 5g equi
- Summary of rendering of water wave and caustics (etching) in webgl
- B站stm32视频学习
- GopherChina 2020大会
猜你喜欢
喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水
LeanCloud 十月变化
Don't release resources in finally, unlock a new pose!
Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process
Leancloud changes in October
Google's AI model, which can translate 101 languages, is only one more than Facebook
Returning to the third place in the world, what did Xiaomi do right?
C++的那些事儿:从电饭煲到火箭,C++无处不在
vim-配置教程+源码
Examples of unconventional aggregation
随机推荐
技术总监7年总结,如何进行正确的沟通?
What is the database paradigm
LeanCloud 十月变化
AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
我们做了一个医疗版MNIST数据集,发现常见AutoML算法没那么好用
使用K3S创建本地开发集群
Alibaba cloud accelerates its growth and further consolidates its leading edge
rabbitmq(一)-基础入门
金融领域首个开源中文BERT预训练模型,熵简科技推出FinBERT 1.0
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
Don't release resources in finally, unlock a new pose!
构建者模式(Builder pattern)
STM32CubeIDE下载安装-GPIO基本配置操作-Debug调试(基于CMSIS DAP Debug)
C++的那些事儿:从电饭煲到火箭,C++无处不在
区块链周报:数字货币发展写入十四五规划;拜登邀请MIT数字货币计划高级顾问加入总统过渡团队;委内瑞拉推出国营加密交易所
B站stm32视频学习
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
svg究竟是什么?
三、函数的参数
How does Alibaba cloud's maxcompute add (original ODPs) work?