update update_password.sh and base.sh
This commit is contained in:
@@ -48,3 +48,15 @@ check_bash_installed() {
|
||||
return 1 # 返回 1 表示 Bash 未安装
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# 生成密码
|
||||
gen_password() {
|
||||
local pass_length=$1 # 密码长度作为第一个参数
|
||||
local chars='[:alnum:]' # 只允许出现字母和数字
|
||||
|
||||
local rand
|
||||
rand=$(< /dev/urandom tr -dc "$chars" | head -c "$pass_length")
|
||||
|
||||
echo "$rand"
|
||||
}
|
||||
Reference in New Issue
Block a user