Add wrapper around openssl_random_pseudo_bytes()
This commit is contained in:
parent
7b1dc582ed
commit
bdee1e9aee
15
MD_STD.php
15
MD_STD.php
|
@ -301,4 +301,19 @@ class MD_STD {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe wrapper around openssl_random_pseudo_bytes.
|
||||
*
|
||||
* @param integer $length Length.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function openssl_random_pseudo_bytes(int $length):string {
|
||||
|
||||
$output = \openssl_random_pseudo_bytes($length);
|
||||
if ($output === false) throw new Exception("Failed generating random pseudo bytes using openssl_random_pseudo_bytes");
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user