函数名称:Random\Randomizer::shuffleBytes()
适用版本:PHP 7.2.0 及以上版本
函数说明:该函数用于随机打乱给定的字节序列。
语法:Random\Randomizer::shuffleBytes(string $bytes): string
参数:
返回值:返回一个打乱后的字节序列。
示例:
// 示例1:打乱一个字符串的字节序列
$string = "Hello World";
$shuffledBytes = Random\Randomizer::shuffleBytes($string);
echo bin2hex($string) . "\n"; // 输出:48656c6c6f20576f726c64
echo bin2hex($shuffledBytes) . "\n"; // 输出类似:6c6f72642048656c6c2057
// 示例2:打乱一个文件的字节序列
$file = 'path/to/file.txt';
$fileBytes = file_get_contents($file);
$shuffledBytes = Random\Randomizer::shuffleBytes($fileBytes);
file_put_contents('path/to/shuffled_file.txt', $shuffledBytes);
注意事项: