90 Snippets: Yet another day of Shell Scripting โก๏ธ๐
90 Projects towards mastery - Day 03 โจ
Hey, fellow tech enthusiasts! Astro here, and I've got something cool to share with you - passgen v1.0, the ultimate password generator! ๐๐ฅ
Link to repo: passgen
Unraveling the Magic: Captivating Code Snippets! ๐๐ฉ
The Colorful Welcome Message: A Glimpse of Enchantment! ๐โจ
code# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
# ... Other color codes ...
# Welcome message
WELCOME_MESSAGE="\\nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n\
... Welcome message content ...
"
# Display welcome message
function DISPLAY_MESSAGE() {
echo -e "${GREEN}${WELCOME_MESSAGE}${RESET}"
}
The Welcome Message casts a spell on users with its vibrant colors and enchanting ASCII art! ๐ซ The color codes are defined at the beginning of the script, adding a touch of magic to the text. The DISPLAY_MESSAGE()
function displays the mesmerizing welcome message and sets the stage for the password generation journey! ๐
Command Line Interface (CLI): Embrace Your Inner Wizard! ๐งโโ๏ธ๐ฎ
code# User input
INPUT=""
# ... Other variable declarations ...
# The CLI loop
function CLI() {
DISPLAY_MESSAGE
while true; do
PROMPT
shopt -s nocasematch
if [[ "${INPUT}" == "GEN" ]]; then
GEN
elif [[ "${INPUT}" == "SHOW" ]]; then
SHOW
elif [[ "${INPUT}" == "SAVE" ]]; then
SAVE
elif [[ "${INPUT}" == "HELP" ]]; then
SHOW_COMMANDS
elif [[ "${INPUT}" == "EXIT" ]]; then
EXIT
else
ERROR
fi
done
}
Behold the CLI, where you take on the role of a tech wizard! ๐งโโ๏ธ The CLI()
function powers the interactive experience, constantly awaiting your command. Upon entering a command, the script uses pattern matching (nocasematch
) to identify the user's intent and calls the respective functions. The CLI loop keeps the magic alive, allowing you to execute commands seamlessly and take full control! ๐งโโ๏ธ๐ฎ
Unleashing the Power of Strong Passwords: The "GEN" Function! ๐๏ธ๐
code# generate a new strong password (at least 16 chars, contains at least: 1 uppercase, 1 lowercase, 1 number, 1 special char)
function GEN() {
PASS=$(openssl rand -base64 48 | cut -c1-16)
echo -e "\tPassword generated successfully! ๐"
}
The "GEN" function is the heart of passgen v1.0! It casts a spell to generate strong and secure passwords, consisting of at least 16 characters with a mix of uppercase, lowercase, numbers, and special characters. The openssl
command brings the magic to life, creating virtually unbreakable passwords! ๐๐
๐ช๐ Unleash the Tech Wizard Within! ๐๐ช
With these captivating code snippets, you now hold the key to unlock the secrets of passgen v1.0! Embrace your inner tech wizard and embark on a journey of password mastery. Let your spells of strong passwords protect your digital realm, making it impervious to any threat. By Thor, By Odin, you are now ready to wield the power of passgen v1.0 and safeguard your digital kingdom! ๐๏ธ๐ปโจ
Unleash Your Inner Tech Wizard with passgen v1.0! ๐โจ
The journey of passgen v1.0 has just begun, and it's time for you to take the reins! Channel your inner tech wizard and dive into the world of secure passwords. Be the guardian of your digital fortress and unlock the secrets of passgen v1.0! Together, we'll make the digital realm a safer place! ๐ฐ๐ก๏ธ
So, let's embark on this thrilling adventure of passgen v1.0, where you'll become a tech wizard like no other! ๐๐ May your passwords be strong, and your tech skills shine brightly! By Thor, By Odin, let's make our mark in the tech realm! ๐ป๐ฎ