如何有人说用md5生成唯一id呢

WBOY
Release: 2016-06-13 10:48:01
Original
1403 people have browsed it

怎么有人说用md5生成唯一id呢?
由于基于系统时间,通过该函数生成的 ID 不是最佳的。如需生成绝对唯一的 ID,请使用 md5() 函数(请在字符串函数参考中查找)。

有人推荐md5(uniqid(rand(), true));这样用.

如果uniqid不能保证绝对不重复, md5毫无作用啊? 因为md5依赖于输入, 和是否唯一无关啊.

------解决方案--------------------
你的理解是对的. 

手册上有这么一段注释, 看起来类似但是含义完全不同: (hmmm,这个中文版手册又滞后了,没有这段)

This function does not generate cryptographically secure tokens, in fact without being passed any additional parameters the return value is little different from microtime(). If you need to generate cryptographically secure tokens use openssl_random_pseudo_bytes().

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!