The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “CPA

password reset

Realpush

Member
affiliate
Hi, we'd like to reactivate activity of our ad network on your forum, but i didn't get password after reset request
 
AI update of my existing bash script remember to chmod +x name.sh :p

1730480459780.png


Bash:
#!/bin/bash

# Configuration
MIN_LENGTH=12
MAX_LENGTH=16
SPECIAL_CHARS='!@#$%^&*_+-='

# Hash-based password generation
generate_hash_based_password() {
    local phrase="${1:-$(date +%s)}"  # Use timestamp if no phrase provided
   
    # Validate input
    if [ -z "$phrase" ]; then
        echo "Error: Please provide a passphrase" >&2
        return 1
    fi
   
    # Echo the passphrase and generate password
    echo "Passphrase: $phrase"
   
    # Generate SHA-256 hash and format
    local hash=$(echo -n "$phrase" | sha256sum | cut -c1-12 | tr '[:lower:]' '[:upper:]')
    local special_char=${SPECIAL_CHARS:$((RANDOM % ${#SPECIAL_CHARS})):1}
    local number=$((RANDOM % 10))
   
    echo "Generated password: ${hash}${special_char}${number}"
}

# Original random password generation
chars='^#$%&_+='
{ </dev/urandom LC_ALL=C grep -ao '[A-Za-z0-9]' \
        | head -n$((RANDOM % 4 + 5))
    echo ${chars:$((RANDOM % ${#chars})):2}   # Random special char.
    echo
} \
    | shuf \
    | tr -d '\n'
echo

# Prompt for passphrase
echo "=== Hash-based Password ==="
echo -n "Enter your passphrase: "
read -r passphrase

# Generate a hash-based password using the entered passphrase
generate_hash_based_password "$passphrase"

# Generate random password
echo -e "\n=== Random Password ==="
echo -n "Random password: "
cat /dev/urandom | tr -dc 'A-Za-z0-9#$%^&*+' | head -c 12
echo

my output is:

1730480565802.png


when I don't add a 'secret' passphrase the epoch (UNIX) date is used:

1730481205922.png


458 seconds has elapsed (time flies --don't it? :D

1730481340724.png


the time delay illustrates the uniqueness of the SHA256 'Generated password: '

........
 

Similar threads

MI
Back