Selaa lähdekoodia

Fix random_key()

Visman 8 vuotta sitten
vanhempi
commit
3414c6a0ce
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      include/functions.php

+ 4 - 1
include/functions.php

@@ -1162,7 +1162,10 @@ function random_key($len, $readable = false, $hash = false)
         $key .= (string) mcrypt_create_iv($len, MCRYPT_DEV_URANDOM);
     }
     if (strlen($key) < $len && function_exists('openssl_random_pseudo_bytes')) {
-        $key .= (string) openssl_random_pseudo_bytes($len);
+        $tmp = (string) openssl_random_pseudo_bytes($len, $strong);
+        if ($strong) {
+            $key .= $tmp;
+        }
     }
     if (strlen($key) < $len) {
         throw new \Exception('Could not gather sufficient random data');