diff --git a/MD_STD.php b/MD_STD.php index ec49462..9ed4f00 100644 --- a/MD_STD.php +++ b/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; + + } + }