perf: replace /dev/urandom | tr with openssl rand to fix CPU spike (#3887)

This commit is contained in:
Yunheng Liu
2026-04-01 07:59:48 -04:00
committed by GitHub
parent 7e6d80efa5
commit 169b216d7e
3 changed files with 25 additions and 22 deletions

View File

@@ -243,8 +243,9 @@ reset_user() {
gen_random_string() {
local length="$1"
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w "$length" | head -n 1)
echo "$random_string"
openssl rand -base64 $(( length * 2 )) \
| tr -dc 'a-zA-Z0-9' \
| head -c "$length"
}
reset_webbasepath() {