upload to github

This commit is contained in:
jrosh 2025-05-30 16:25:30 +02:00
commit 7d3dfb9c69
No known key found for this signature in database
GPG key ID: A4D68DCA6C9CCD2D
6 changed files with 455 additions and 0 deletions

21
pwgen.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# Function to generate a random password
generate_password() {
local length=$1
if ! [[ "$length" =~ ^[0-9]+$ ]] || [ "$length" -le 0 ]; then
echo "Please provide a valid positive integer for password length."
exit 1
fi
local charset='A-Z:a-z:0-9:!@#$%^&*()_+[]{}|;:,.<>?'
# Generate the password
local password=$(cat /dev/urandom | tr -dc "$charset" | fold -w "$length" | head -n 1)
echo "$password"
}
if [ $# -ne 1 ]; then
echo "Usage: $0 <length>"
exit 1
fi
generate_password "$1"