Password validation  Write a program password.py that reads a file containing multiple passwords and checks the validity of the passwords.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.5: A Case Study: Pollen Count File Update
Problem 4E
icon
Related questions
Question

Password validation 

Write a program password.py that reads a file containing multiple passwords and checks the validity of the passwords. The file format is identical to one of the sample passwords.txt provided below. Your program must contain the following functions:

Function name

Function description

Function input(s)

Function return value(s)

validate()

This function takes a password string as input and returns a boolean that determines if the password is valid or invalid.

The requirements for a valid password are:

  • The password must be at least 9 characters long and at most 18 characters long (included).

  • The password must end with a letter.

  • The ending letter must be uppercase.

  • The password must contain `62`

  • The password must not start with `@`

  • The password must contain at least 4 digits

Password string

Boolean

main()

This function prompts for a file of passwords.

Next, it opens the file.

Next, it checks for the validity of every password in the file using the function validate() and prints the validity of the password.

None

None

Use the starter code here:

 

def validate(password):

           """

           This function validates a password and returns a boolean that determines if the password is valid of invalid.              """

            is_valid = False

            # todo

            return is_valid

def main():

             """

             This function prompts for a file of passwords. Next, it opens the file. Next, it checks for the validity of every password in the file using the function validate() and prints the validity of the password.

            """

            filename = input("Enter the password file name: ")

            print()

             with open(filename, 'r') as content:

                    pass

                   

# todo if __name__ == '__main__': main()

Here are example passwords that couldve been in a file to use:

 

Q1Wb62YXn8EdtP 32489962 dKaxKXlLpp gT00D2W62effecT 2622wgkOIHRkC Er~_6w`@ws'&d 2S)'8Dp9e Zw62>8}mh<_@NqW9G J+979K62//T! 3P7sam:vX62}W p5mn6209&RgFN@gX

Example

Enter the password file name: passwords.txt


Q1Wb62YXn8EdtP is valid

32489962 is invalid

dKaxKXlLpp is invalid

gT00D2W62effecT is valid

2622wgkOIHRkC is valid

Er~_6w`@ws'&d is invalid

2S)'8Dp9e is invalid

Zw62>8}mh<_@NqW9G is valid

J+979K62//T! is invalid

3P7sam:vX62}W is valid

p5mn6209&RgFN@gX is valid

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
User Defined DataType
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr