From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- .../random_compat/random_bytes_libsodium.php | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 srcs/wordpress/wp-includes/random_compat/random_bytes_libsodium.php (limited to 'srcs/wordpress/wp-includes/random_compat/random_bytes_libsodium.php') diff --git a/srcs/wordpress/wp-includes/random_compat/random_bytes_libsodium.php b/srcs/wordpress/wp-includes/random_compat/random_bytes_libsodium.php new file mode 100644 index 0000000..4af1a24 --- /dev/null +++ b/srcs/wordpress/wp-includes/random_compat/random_bytes_libsodium.php @@ -0,0 +1,88 @@ + 2147483647) { + $buf = ''; + for ($i = 0; $i < $bytes; $i += 1073741824) { + $n = ($bytes - $i) > 1073741824 + ? 1073741824 + : $bytes - $i; + $buf .= \Sodium\randombytes_buf($n); + } + } else { + $buf = \Sodium\randombytes_buf($bytes); + } + + if ($buf !== false) { + if (RandomCompat_strlen($buf) === $bytes) { + return $buf; + } + } + + /** + * If we reach here, PHP has failed us. + */ + throw new Exception( + 'Could not gather sufficient random data' + ); + } +} -- cgit