Question

Using Python, generate a random password which meets these rules and show five examples of the...

Using Python, generate a random password which meets these rules and show five examples of the random passwords.

rules: password contains 6-20 characters, contain at least one lowercase letter, at least one uppercase letter, and at least one digit, must not contain three repeating characters in a row ("...aaa..." is weak, but "...aa...a..." is strong, assuming other conditions are met).

Homework Answers

Answer #1
import random
import string

def get_random_password():
    random_source = string.ascii_letters + string.digits
    password = random.choice(string.ascii_lowercase)
    password += random.choice(string.ascii_uppercase)
    password += random.choice(string.digits)
    
    print("please enter length of password in range 6 - 20")
    length=int(input())
    for i in range(length-4):
        password += random.choice(random_source)

    password_list = list(password)
    random.SystemRandom().shuffle(password_list)
    password = ''.join(password_list)
    if(len(password)>=6 and len(password)<=20):
        return password
    else:
        return "length was invalid"
        
print(get_random_password())

Please check the code. I hope it helps/

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Imagine you are developing a software package that requires users to enter their own passwords. Read...
Imagine you are developing a software package that requires users to enter their own passwords. Read the input as a C-string or a string object. Your software requires that users’ passwords be sent to special functions that will verify if the characters used meet the following criteria: The password should be at least six characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. Write a...
A company wants to impose a more secure password system for its employees to use on...
A company wants to impose a more secure password system for its employees to use on the company’s network. The current policy requires a minimum of seven characters. The system under consideration requires a minimum of eight characters. The new system will allow repetition of characters, but not doubling (e.g., the sequence 121 would be acceptable, but not 112). For both password systems, assume the following: Only alphanumeric characters can be used in the passwords, without any spaces or symbols....
Motorola has developed an edible password pill. When the pill is ingested, it is activated by...
Motorola has developed an edible password pill. When the pill is ingested, it is activated by the acid in your stomach emitting an 18-bit signal which is strong enough to communicate and unlock all your devices. The edible password pill won’t be available in the near future, but it is already FDA approved. A computer system uses passwords that contain exactly six characters, and each character is one of 26 lower case letters (a, z), 26 upper case letters (A,...
1- A particular automatic sprinkler system has two different types of activation devices for each sprinkler...
1- A particular automatic sprinkler system has two different types of activation devices for each sprinkler head. One type has a reliability of 0.87; that is, the probability that it will activate the sprinkler when it should is 0.87. The other type, which operates independently of the first type, has a reliability of 0.77. If either device is triggered, the sprinkler will activate. Suppose a fire starts near a sprinkler head. a) What is the probability that the sprinkler head...