当前位置:网站首页>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
边栏推荐
- Restfulapi learning notes -- father son resources (4)
- 别再在finally里面释放资源了,解锁个新姿势!
- Rabbitmq (1) - basic introduction
- Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization
- TypeScript(1-2-2)
- What is the database paradigm
- vim-配置教程+源码
- Golang 系统ping程序探测存活主机(任意权限)
- RestfulApi 学习笔记——父子资源(四)
- 契约式设计(Dbc)以及其在C语言中的应用
猜你喜欢

How to solve the difference between NAT IP and port IP

markdown使用

小青台正式踏上不归路的第3天

Flink: from introduction to Zhenxiang (3. Reading data from collection and file)

Learn to record and analyze

Alibaba cloud accelerates its growth and further consolidates its leading edge

佛萨奇forsage以太坊智能合约是什么?以太坊全球滑落是怎么回事

STM32CubeIDE下载安装-GPIO基本配置操作-Debug调试(基于CMSIS DAP Debug)

2020-11-05

模板引擎的整理归纳
随机推荐
Android Basics - check box
Is there no way out for older programmers?
Arduino IDE搭建ESP8266开发环境,文件下载过慢解决方法 | ESP-01制作WiFi开关教程,改造宿舍灯
Station B STM32 video learning
软件开发中如何与人协作? | 每日趣闻
CSP考试须知与各种小技巧
机械硬盘随机IO慢的超乎你的想象
[Python 1-6] Python tutorial 1 -- number
聊聊Go代码覆盖率技术与最佳实践
浅谈,盘点历史上有哪些著名的电脑病毒,80%的人都不知道!
[开源] .Net 使用 ORM 访问 华为GaussDB数据库
别再在finally里面释放资源了,解锁个新姿势!
Xiaoqingtai officially set foot on the third day of no return
SQL 速查
API生命周期的5个阶段
学习记录并且简单分析
2020-11-05
Design by contract (DBC) and its application in C language
Do these mistakes in your resume affect your annual salary of one million?
阿里云的MaxCompute数加(原ODPS)用的怎样?