From eecfb9a999b5fc03e2b0081f746fd853c11a4788 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 11 Mar 2023 16:48:53 +0700 Subject: [PATCH] Simplified make_rand_str function https://github.com/torrentpier/torrentpier/pull/575 Fixed: PHP Notice: crypt(): No salt parameter was specified. You must use a randomly generated salt and a strong hash function to produce a secure hash. --- common.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/common.php b/common.php index 68d47bf0..113bcc7a 100644 --- a/common.php +++ b/common.php @@ -301,12 +301,7 @@ function str_compact ($str) function make_rand_str ($len = 10) { - $str = ''; - while (strlen($str) < $len) - { - $str .= str_shuffle(preg_replace('#[^0-9a-zA-Z]#', '', crypt(uniqid(mt_rand(), true)))); - } - return substr($str, 0, $len); + return substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', (int)$len)), 0, $len); } // bencode: based on OpenTracker