男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

openssl_random_pseudo_bytes

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

openssl_random_pseudo_bytes生成一個(gè)偽隨機字節串

說(shuō)明

openssl_random_pseudo_bytes(int $length, bool &$crypto_strong = ?): string

生成一個(gè)偽隨機字節串 string ,字節數由 length 參數指定。

通過(guò) crypto_strong 參數可以表示在生成隨機字節的過(guò)程中是否使用了強加密算法。返回值為false的情況很少見(jiàn),但已損壞或老化的有些系統上會(huì )出現。

參數

length

所需字節串的長(cháng)度,必須為正整數。PHP會(huì )試著(zhù)將該參數轉換為非空整數來(lái)使用它。

crypto_strong

如果傳遞到該函數中,將會(huì )保存為一個(gè) boolean 值來(lái)表明是否使用了“強加密”,如果被用于GPG和密碼之類(lèi)的將返回true , 否則返回 false

返回值

成功,返回生成的字節串 string , 或者在失敗時(shí)返回 false.

范例

示例 #1 openssl_random_pseudo_bytes() 范例:

<?php
for ($i = -1$i <= 4$i++) {
    
$bytes openssl_random_pseudo_bytes($i$cstrong);
    
$hex   bin2hex($bytes);

    echo 
"Lengths: Bytes: $i and Hex: " strlen($hex) . PHP_EOL;
    
var_dump($hex);
    
var_dump($cstrong);
    echo 
PHP_EOL;
}
?>

以上例程的輸出類(lèi)似于:

Lengths: Bytes: -1 and Hex: 0
string(0) ""
NULL

Lengths: Bytes: 0 and Hex: 0
string(0) ""
NULL

Lengths: Bytes: 1 and Hex: 2
string(2) "42"
bool(true)

Lengths: Bytes: 2 and Hex: 4
string(4) "dc6e"
bool(true)

Lengths: Bytes: 3 and Hex: 6
string(6) "288591"
bool(true)

Lengths: Bytes: 4 and Hex: 8
string(8) "ab86d144"
bool(true)

參見(jiàn)

  • random_bytes() - Generates cryptographically secure pseudo-random bytes
  • bin2hex() - 函數把包含數據的二進(jìn)制字符串轉換為十六進(jìn)制值
  • crypt() - 單向字符串散列
  • mt_rand() - 生成更好的隨機數
  • uniqid() - 生成一個(gè)唯一ID
男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站