Random\Randomizer::getBytes

(PHP 8 >= 8.2.0)

Random\Randomizer::getBytesランダムなバイト列を取得する

説明

public Random\Randomizer::getBytes(int $length): string

警告

この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。

パラメータ

length

返すべきランダムな文字列の長さをバイト単位で指定します。1 以上でなければなりません。

戻り値

指定された長さの、ランダムなバイト列を含んだ文字列を返します。

エラー / 例外

例1 Random\Randomizer::getBytes() の例

<?php
$r
= new \Random\Randomizer();

echo
bin2hex($r->getBytes(8)), "\n";
?>

上の例の出力は、 たとえば以下のようになります。

ebdbe93cd56682c2

参考

  • random_bytes() - 暗号学的にセキュアな、ランダムなバイト列を生成する
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top