Добавить passwd-gen.sh
This commit is contained in:
51
passwd-gen.sh
Normal file
51
passwd-gen.sh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
generate_password() {
|
||||
local length="$1"
|
||||
tr -dc A-Za-z0-9_\!\@\#\$\%\&\*\(\) < /dev/urandom | head -c "$length"
|
||||
echo
|
||||
}
|
||||
|
||||
passwords_file="password.txt"
|
||||
|
||||
echo "Адрес электронной почты?"
|
||||
read email_choice
|
||||
|
||||
email_choice_lower=$(echo "$email_choice" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
if [[ "$email_choice_lower" == "yes" || "$email_choice_lower" == "y" ]]; then
|
||||
read -p "Введите адрес электронной почты: " email
|
||||
fi
|
||||
|
||||
echo "Cгенерировать пароль?:"
|
||||
read generate_choice
|
||||
|
||||
generate_choice_lower=$(echo "$generate_choice" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
if [[ "$generate_choice_lower" == "yes" || "$generate_choice_lower" == "y" ]]; then
|
||||
echo "Введите длину пароля:"
|
||||
read password_length
|
||||
generated_password=$(generate_password "$password_length")
|
||||
else
|
||||
read -s -p "Введите пароль: " user_password
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "Введите название сервиса:"
|
||||
read service_name
|
||||
|
||||
echo "Сервис: $service_name" >> "$passwords_file"
|
||||
|
||||
if [[ "$generate_choice_lower" == "yes" || "$generate_choice_lower" == "y" ]]; then
|
||||
echo "Пароль: $generated_password" >> "$passwords_file"
|
||||
else
|
||||
echo "Пароль: $user_password" >> "$passwords_file"
|
||||
fi
|
||||
|
||||
if [[ "$email_choice_lower" == "yes" || "$email_choice_lower" == "y" ]]; then
|
||||
echo "Почта: $email" >> "$passwords_file"
|
||||
fi
|
||||
|
||||
echo "" >> "$passwords_file"
|
||||
|
||||
echo "Информация сохранена в $passwords_file"
|
||||
Reference in New Issue
Block a user