PHP CSPRNG
CSPRNG(????? ??? ?? ?? ???, ?? ?? ???).
PHP 7? ?? CSPRNG ??? ???? ???? ??? ??? ???? ??? ????? ?????.
random_bytes() - ???? ??? ?? ?? ??????.
random_int() - ???? ??? ?? ?? ?????.
random_bytes()
Syntax format
string random_bytes ( int $length )
Parameters
length - ?? ????? ??? ??? ????.
?? ?
???? ???? ??? ??? ??? ?? ???? int ?? ?? ?? ??? ?????.
Instance
<?php $bytes = random_bytes(5); print(bin2hex($bytes)); ?>
? ???? ??? ?? ??? ??? ????.
6f36d48a29
random_int()
Syntax format
int random_int ( int $min , int $max )
Parameters
min - ??? ??? ?? ? ?? ???. PHP_INT_MIN ?????.
max - ??? ???? PHP_INT_MAX ???? ???.
?? ?
??? ?? ?? ?? ??? ?????.
Instance
<?php print(random_int(100, 999)); print(PHP_EOL); print(random_int(-1000, 0)); ?>
? ???? ??? ?? ??? ??? ????.
723 -64