blocktrail/simply-random

一个用于生成安全随机数(字符串、整数、洗牌)的简单库

v2.0.0 2017-01-04 11:50 UTC

This package is auto-updated.

Last update: 2024-09-23 05:25:14 UTC


README

Latest Stable Version Build Status

5.67.07.1HHVM 上测试过

这个库是什么?

这是一个使用 random_bytes 生成随机数的简单库。
这个库可以生成强加密的随机数和其他有用的随机值。

依赖

此库依赖于 random_bytes 或 ParagonIE 提供的 polyfill。如果作为本地扩展提供,则使用内核 CSPRNG。polyfill 处理检查熵源,如果不可用。

安装

只需使用 composer require blocktrail/simply-random ~1.0

用法

请参阅 test.php 以获取示例用法。

归功于 ircmaxell

此库中使用的代码大部分最初由 ircmaxellrandom_compat 编写。此库最初是一个简化复杂性且高度依赖 mcrypt 的分支。

参阅: http://timoh6.github.io/2013/11/05/Secure-random-numbers-for-PHP-developers.html

以及更多:https://news.ycombinator.com/item?id=6216101 http://security.stackexchange.com/questions/3936/is-a-rand-from-dev-urandom-secure-for-a-login-key/3939#3939