Question

In: Computer Science

Password Checking Software to reset passwords often requires the user to enter the password twice, checking...

Password Checking
Software to reset passwords often requires the user to enter the password twice, checking to make sure it was entered the same way both times. Write a program in Python that contains functions/methods in it that can verify that the two passwords entered are correct. Your project should contain a method that asks the user to enter a password twice, then either tell the user that the two entries were not the same and then start the process over again. Or, if they are the same, tell the user that the new password was accepted.

Additionally, the user is required to enter a password that meets specific security requirements. Proper Passwords are required to follow these rules:

  • The password must be at least 12 characters long.
  • The password must contain at least:
    - one alpha character [a-zA-Z];
         - one numeric character [0-9];
         - one character that is not alpha or numeric, such as
                  “! @ $ % ^ & * ( ) - _ = + [ ] ; : ' " , < . > / ?” this is an example, all non-alpha or numeric characters should be included.
  • The password must not:
    - Contain spaces;
        - Or, begin with a non-alpha-numeric character;
  • Finally, the password cannot contain repeating character strings of 2 or more identical characters, such as “11” or “aa”.

Your task is to create a project to verify whether or not a prospective proper password meets these requirements and that the user has entered the correct password in twice. Hint, a modular solution to this assignment will be the most efficient approach to meeting the requirements of this project

The project should identify to the user the types of rule violations that are contained in an improperly entered password

The project should use a modular solution using user-defined functions

Solutions

Expert Solution

import re

def main():
    
    #prompts user to enter password
    pwd1 = input("Enter password: ")
    
    #prompts user to reenter password
    pwd2 = input("Enter password again: ")
    
    #declare the string of special characters
    special_characters = "!@$%^&*()-_=+[];:'\",<.>/?"
    
    #initialize valid to 1
    valid = 1
    
    #checks if pwd1 is equal to pwd2 or not
    if(pwd1 == pwd2):
        
        #if pwd1 = pwd2 then cheks for validation of password
        while True:  
            
            #cheks if password have min length 12 or not
            #if min length <12 then set valid = 0
            if (len(pwd1)< 12): 
                print("Password must have minimum length 12")
                valid = 0
                break
            
            #cheks if password contain atleast 1 lower case character or not
            #if password not contain atleast 1 lower case then set valid = 0   
            elif not re.search("[a-z]",pwd1):
                print("Password must contain atleast 1 lower case character")
                valid = 0
                break
            
            #cheks if password contain atleast 1 upper case character or not
            #if password not contain atleast 1 upper case then set valid = 0      
            elif not re.search("[A-Z]",pwd1):
                print("Password must contain atleast 1 upper case character")
                valid = 0
                break
            
            #cheks if password contain atleast 1 digit or not
            #if password not contain atleast 1 digit then set valid = 0  
            elif not re.search("[0-9]",pwd1):
                print("Password must contain atleast 1 digit")
                valid = 0
                break
                
            #cheks if password contain atleast 1 special character or not
            #if password not contain atleast 1 special character then set valid = 0    
            elif not any(c in special_characters for c in pwd1):
                print("Password must contain atleast 1 special charater")
                valid = 0
                break
            
            #cheks if password contain space or not
            #if password contain space then set valid = 0
            elif(re.search(r"\s", pwd1)):
                print("Password must not contain space")
                valid = 0
                break
            
            #cheks if password start with alpha numeric character or not
            #if password not start with alpha numeric character then set valid = 0    
            elif(not pwd1[0].isalnum()):
                print("Password must start with alpha numeric character")
                valid = 0
                break
            
            #cheks if password contain repeating character or not
            #if password contain repeating character then set valid = 0   
            elif valid == 1:    
                for i in range(len(pwd1) -1):
                    if(pwd1[i] == pwd1[i+1]):
                        print("Password must not contain repeating character")
                        valid = 0 
                        break
                if(valid == 0):
                    break
                
            
            #if valid = 1 that means all validation are passed
            #then prints New password is accepted
            if valid == 1:
                print("New password is accepted")
                break
            
    #if pwd1 and pwd2 are not same         
    else:
        print("Two entries are not the same")
        valid = 0
    
    #if valid = 0 then call main() function     
    if valid == 0:
        main()
    
main()

OUTPUT:


Related Solutions

Imagine you are developing a software package that requires users to enter their own passwords. Your...
Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that users' passwords meet the following criteria: The password should be at least six characters long. The password should be at least one uppercase and at least one lowercase letter. The password should have at least one digit. Write a program that asks for a password then verifies that it meets the stated criteria. If it doesn't, the program should display a...
Imagine you are developing a software package that requires users to enter their own passwords. Your...
Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that user’s passwords meet the following criteria: 1. The password should be at least six characters long. 2. The password should contain at least one uppercase and at least one lowercase letter. 3. The password should have at least one digit. Write a program that asks for a password and then verifies that it meets the stated criteria. If it doesn’t, the...
A password verification system that does not allow user passwords to be proper names or words...
A password verification system that does not allow user passwords to be proper names or words that are normally included in a dictionary is an example of ___________ with respect to security systems. Group of answer choices Attack Risk Asset Countermeasure
C# Create an application that asks the user to enter their new password. The password must...
C# Create an application that asks the user to enter their new password. The password must be at least 6 characters long. Develop a custom exception handling case that checks for the password length. (hint: use " .Length " built-in method). If the new password is less than 6 characters long the custom exception should output an error message.
Using C++ Write a program to ask user to enter a password and validity the password....
Using C++ Write a program to ask user to enter a password and validity the password. The password should be 8 – 20 characters long (8 is included and 20 is included), it should contain at least one uppercase letter and one lower case letter. The password should contain at least one digit, and at least one symbol other than alphabets or numbers. Most importantly, the password may not contain any white space. Functions: You will need at least the...
In.java Write a program that repeatedly asks the user to enter their password until they enter...
In.java Write a program that repeatedly asks the user to enter their password until they enter the correct one. However, after 5 failed attempts, the program "locks out" the user. We will show that with an error message. Assume the password is HOC2141 (case sensitive). Note that there is a special case that is not shown below. To identify it, think of all possible scenarios of input for this program. ----------- Sample run 1: Enter your password: Blake Wrong Enter...
4.15 LAB: Password modifier Many user-created passwords are simple and easy to guess. Write a program...
4.15 LAB: Password modifier Many user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string
22.7. Services that require a password often impose constraints to prevent the user from choosing a...
22.7. Services that require a password often impose constraints to prevent the user from choosing a password that is easy to guess. Consider a service that requires an 8-character password, using the 26 Roman letters (both lowercase and uppercase) and the 10 Arabic numerals. (a) How many possible passwords are there? (b) How many such passwords use no numerals? No lowercase letters? No uppercase letters?
Forms often allow a user to enter an integer. Write a program that takes in a...
Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or any string with a non-integer character, the output is: no PYTHON 3
Forms often allow a user to enter an integer. Write a programthat takes in a...
Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT