php mcrypt_create_iv 的替代openssl_random_pseudo_bytes

在新版本php 7.3 已经没有了mcrypt模块

比如 要生成一个随机IV
老版本 mcrypt_create_iv($len=16, MCRYPT_DEV_RANDOM)
新方法这样做
$length=16;
$strong=true;
$openssl_rand=bin2hex(openssl_random_pseudo_bytes($length, $strong));
echo $openssl_rand;
//输出随机HEX,共32个字符
//8244df553b54831e8070a4be10135e7e

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注