From: Tim Düsterhus Date: Thu, 3 Jan 2019 13:10:38 +0000 (+0100) Subject: Implement StringUtil::getUUID() in terms of a CSPRNG X-Git-Tag: 5.2.0_Alpha_1~371^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c2479cf23d970aa67788ad8edb9d9a3b33e74f3a;p=GitHub%2FWoltLab%2FWCF.git Implement StringUtil::getUUID() in terms of a CSPRNG --- diff --git a/wcfsetup/install/files/lib/util/StringUtil.class.php b/wcfsetup/install/files/lib/util/StringUtil.class.php index 36a556687a..9de5d0771a 100644 --- a/wcfsetup/install/files/lib/util/StringUtil.class.php +++ b/wcfsetup/install/files/lib/util/StringUtil.class.php @@ -56,7 +56,21 @@ final class StringUtil { * @return string */ public static function getUUID() { - return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)); + return sprintf( + '%04x%04x-%04x-%04x-%02x%02x-%04x%04x%04x', + // time_low + random_int(0, 0xffff), random_int(0, 0xffff), + // time_mid + random_int(0, 0xffff), + // time_hi_and_version + random_int(0, 0x0fff) | 0x4000, + // clock_seq_hi_and_res + random_int(0, 0x3f) | 0x80, + // clock_seq_low + random_int(0, 0xff), + // node + random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff) + ); } /**