增加生成密码功能

This commit is contained in:
Olia Lisa
2025-12-29 17:24:26 +08:00
parent 47f66bee9b
commit daddf70090
2 changed files with 34 additions and 0 deletions
+13
View File
@@ -84,3 +84,16 @@ install_docker_compose(){
chmod +x /usr/local/bin/docker-compose
}
# 生成密码
gen_password() {
local pass_length=$1 # 密码长度作为第一个参数
local chars='[:alnum:]' # 只允许出现字母和数字
local rand
rand=$(< /dev/urandom tr -dc "$chars" | head -c "$pass_length")
echo "$rand"
}