在Linux上的PHP 5.6中未定义bintohex()和random_bytes()函数

Dea*_*der 0 php linux apache centos

我正试着打电话

echo bintohex(random_bytes(30));
Run Code Online (Sandbox Code Playgroud)

但我的日志显示

PHP Fatal error:  Call to undefined function bintohex()
Run Code Online (Sandbox Code Playgroud)

PHP 5.6.17
Apache 2.2.15
CentOS 6.7
Mcrypt 2.5.8 (在phpinfo()页面上安装和验证)
extension = mcrypt.so (present)

任何想法为什么我找不到bintohex()或random_bytes()函数?

zr9*_*zr9 5

因为它bin2hex http://php.net/manual/en/function.bin2hex.php不是"bintohex"

random_bytes只有在Php 7基本上存在根据文档http://php.net/random_bytes但这里是填充工具到5.x版本https://github.com/paragonie/random_compat

  • 另:http://php.net/manual/en/function.openssl-random-pseudo-bytes.php (2认同)