瀏覽代碼

Fix random_key()

Visman 8 年之前
父節點
當前提交
3414c6a0ce
共有 1 個文件被更改,包括 4 次插入1 次删除
  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');