SHELL SCRIPT to generate random PASSWORD and CAPTCHA

1). create a file named "password.sh"
 
#!/bin/bash
while :
do
    clear
    cat<<EOF
                ===================
                PASSWORD GENERATOR:
                -------------------
            Enter the (P)assword length
            Enter the (C)aptcha length
                      (Q)uit
                -------------------
EOF
    read -n1 -s
    case "$REPLY" in
    "E")
    echo -e -n "\n\t: "
    read b
    a=$(tr -dc "A-Za-z0-9~!@#$%^&*-_" < /dev/urandom | head -c$b)
    echo -e "\n\n\t\t$a"
    ;;
    "C")
    echo -e -n "\n\t: "
    read b
    echo -e "\n\n\t\t" `/usr/bin/shuf -i 1-$b -z`
    ;;
    "Q")  exit 0                    ;;
    "q")  echo "case sensitive!!"   ;;
    "c")  echo "case sensitive!!"   ;;
    "e")  echo "case sensitive!!"   ;;
    esac
    sleep 2
done

2). copy & paste the below code in file: password.sh

3). chmod 755  password.sh

4). ./password.sh
output:



for PASSWORD:



 for CAPTCHA:



Press Q (not "q") to exit.

=========================
Simple script for only PASSWORD:
=========================

 #!/bin/bash
b=$1
if [ $# -gt 1 ] || [ $# -eq 0 ]
then
echo "Enter the password length:"
read b
a=$(tr -dc "A-Za-z0-9~!@#$%^&*-_" < /dev/urandom | head -c$b)
echo "$a"
else
a=$(tr -dc "A-Za-z0-9~!@#$%^&*-_" < /dev/urandom | head -c$b)
echo "$a"
fi
=========================

Comments

Popular posts from this blog

Resolved: DOCKER: Error response from daemon: Could not attach to network / rpc error: code = 7 desc = network not manually attachable.

yum failed 6 times. Cannot continue!

unexpectedly shrunk window (repaired) in dmesg log - TCP Peer