Skip to content

Commit 8aba3ae

Browse files
authored
fix: unable to pass odd number to genRandomChar (#2403)
* fix: unable to pass odd number to genRandomChar
1 parent 20ba56d commit 8aba3ae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Utils/Tools.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ public static function genRandomChar(int $length = 8): string
186186
$length = 2;
187187
}
188188

189-
return bin2hex(openssl_random_pseudo_bytes($length / 2));
189+
$randomString = bin2hex(openssl_random_pseudo_bytes((int) ceil($length / 2)));
190+
return substr($randomString, 0, $length);
190191
}
191192

192193
public static function genSs2022UserPk(string $passwd, string $method): string|false

0 commit comments

Comments
 (0)