generating password in sh
generating password in sh enjoyunknown
sh
a year ago
836 B
17
Indexable
#!/bin/bash # Function to generate a random password generate_password() { # Define the character set for the password char_set="A-Za-z0-9!@#$%^&*()_+=-" # Generate a password of length 12 password=$(head /dev/urandom | tr -dc "$char_set" | head -c 12) echo "$password" } # Function to display the menu display_menu() { echo "Menu:" echo "1. Generate Random Password" echo "2. Exit" } # Main script while true; do display_menu read -p "Enter your choice: " choice case $choice in 1) echo "Random Password: $(generate_password)" ;; 2) echo "Exiting..." exit 0 ;; *) echo "Invalid choice. Please enter a valid option." ;; esac done
Editor is loading...
Leave a Comment