program to generate random password and the minimum length is a digit | Web Scripts | Crax

Welcome To Crax.Pro Forum!

Check our new Marketplace at Crax.Shop

   Login! SignUp Now!
  • We are in solidarity with our brothers and sisters in Palestine. Free Palestine. To learn more visit this Page

  • Crax.Pro domain has been taken down!

    Alternatives: Craxpro.io | Craxpro.com

program to generate random password and the minimum length is a digit

program to generate random password and the minimum length is a digit

LV
1
 

yohilax951

Member
Joined
Dec 20, 2023
Threads
67
Likes
32
Awards
5
Credits
3,745©
Cash
0$
import random
import string

def generate_password(min_length):
if min_length < 1:
print("Minimum length should be at least 1.")
return

# Ensure at least one digit
password = [random.choice(string.digits)]

# Add random characters to meet the minimum length
password += [random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(min_length - 1)]

# Shuffle the password to randomize the order
random.shuffle(password)

return ''.join(password)

# Example: Generate a password with a minimum length of 8 characters
min_length = 8
random_password = generate_password(min_length)
print("Random Password:", random_password)
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

Top Bottom