think-wxminihelper
think-wxminihelper copied to clipboard
Notice: Can not open /dev/urandom.
请问怎么解决,我是linux服务器
不同厂商的服务器获取随机数的方法不同吧,我用的是centos系统就是这个
我也是centos 但是报错
存的是sessionKey+openId 我怎么通过3rdsession获取到openId啊
You can use CSPRNG functions instead in php7 or higher versions to generate random numbers. It will use getrandom(2) or /dev/urandom on Linux. See https://secure.php.net/manual/zh/function.random-bytes.php
微信官方的签名算法改变了,https://mp.weixin.qq.com/debug/wxadoc/dev/api/signature.html,到这里下载示例,将WXBizDataCrypt类和ErrorCode类覆盖到这个项目的类中就解决了问题。希望作者有空去修改一下。
Replace with
function RandomToken($length = 32){
if(!isset($length) || intval($length) <= 8 ){
$length = 32;
}
if (function_exists('random_bytes')) {
return bin2hex(random_bytes($length));
}
if (function_exists('openssl_random_pseudo_bytes')) {
return bin2hex(openssl_random_pseudo_bytes($length));
}
if (function_exists('mcrypt_create_iv')) {
return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
}
}