当前位置:网站首页>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
边栏推荐
- How to cooperate with people in software development? |Daily anecdotes
- On the concurrency of update operation
- 2020-11-05
- 2035我们将建成这样的国家
- Workers, workers soul, draw lifelong members, become a person!
- 10 common software architecture patterns
- Flink: from introduction to Zhenxiang (6. Flink implements UDF function - realizes more fine-grained control flow)
- What is the database paradigm
- AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
- jsliang 求职系列 - 07 - Promise
猜你喜欢

【Python 1-6】Python教程之——数字

Builder pattern

Application of four ergodic square of binary tree

Learn to record and analyze

腾讯:阿里的大中台虽好,但也不是万能的!

laravel8更新之速率限制改进

LiteOS-消息队列

Tips and skills of CSP examination

Millet and oppo continue to soar in the European market, and Xiaomi is even closer to apple

Talking about, check the history of which famous computer viruses, 80% of the people do not know!
随机推荐
一分钟全面看懂forsage智能合约全球共享以太坊矩阵计划
Learn to record and analyze
How to solve the difference between NAT IP and port IP
wanxin finance
Golang system ping program to detect the surviving host (any permission)
Arduino IDE搭建ESP8266开发环境,文件下载过慢解决方法 | ESP-01制作WiFi开关教程,改造宿舍灯
2035 we will build such a country
markdown使用
佛萨奇forsage以太坊智能合约是什么?以太坊全球滑落是怎么回事
DeepMind 最新论文解读:首次提出离散概率树中的因果推理算法
阿里云的MaxCompute数加(原ODPS)用的怎样?
Solution to the problem of offline connection between ADB and mobile phone
Golang ICMP协议探测存活主机
Eight ways to optimize if else code
Suitable for C / C + + novice learning some projects, do not give me to miss!
The network adapter could not establish the connection
Flink: from introduction to Zhenxiang (6. Flink implements UDF function - realizes more fine-grained control flow)
二叉树的四种遍历方应用
I used Python to find out all the people who deleted my wechat and deleted them automatically
Essential for back-end programmers: distributed transaction Basics