Using command line tools that can generate random data and manipulting string we can generate random passwords.
Here we are going to use openssl rand -base64 command to generate random data of user define lengths.and the genreted data we are going to save in file.
The rand
command in OpenSSL is used to generate random data
The Base64 format, which is a standardized format for encoding binary data as printable ASCII characters.
#!/bin/bash
echo "Random Password Generator"
echo "Enter The Length Of The Password: "
read LENGTH
echo "Enter a Username: "
read USERNAME
PASSWORD=$(openssl rand -base64 $LENGTH)
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "$USERNAME,$PASSWORD,$TIMESTAMP" >> passwords_file.csv
echo "Your new password for $USERNAME is: $PASSWORD"