Skip to content

Commit 3a04ba9

Browse files
authored
Merge pull request #77 from Mannuel25/master
Addition Of Password Validator Script
2 parents d63b18c + 9839951 commit 3a04ba9

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed

Password Validator/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Password Validator
2+
3+
This program validates passwords to match specific rules. A valid password is one that conforms to the following rules:
4+
- Minimum length is 6;
5+
- Maximum length is 12;
6+
- Contains at least an uppercase letter or a lowercase letter
7+
- Contains at least a number;
8+
- Contains at least a special character (such as @,+,£,$,%,*^,etc);
9+
- Doesn't contain space(s).
10+
11+
# Prerequisites
12+
13+
It requires no prerequisites, you only need to run the script. If you don't have Python installed, you can visit [here](https://www.python.org/downloads/) to download Python.
14+
15+
# How to run the script
16+
17+
Running the script is pretty easy, open a terminal in the folder where your script is located and run the following command :
18+
19+
`python main.py`
20+
21+
# Sample use of the script
22+
23+
![alt text](https://github.com/Mannuel25/Python-scripts-collection/blob/master/Password%20Validator/screenshot_1.png)
24+
25+
![alt text](https://github.com/Mannuel25/Python-scripts-collection/blob/master/Password%20Validator/screenshot_2.png)
26+
27+
![alt text](https://github.com/Mannuel25/Python-scripts-collection/blob/master/Password%20Validator/screenshot_3.png)
28+
29+
# Author's name
30+
31+
[Emmanuel Tanimowo](https://github.com/Mannuel25)

Password Validator/main.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import string
2+
3+
def passwordValidator():
4+
"""
5+
Validates passwords to match specific rules
6+
: return: str
7+
"""
8+
# display rules that a password must conform to
9+
print('\nYour password should: ')
10+
print('\t- Have a minimum length of 6;')
11+
print('\t- Have a maximum length of 12;')
12+
print('\t- Contain at least an uppercase letter or a lowercase letter')
13+
print('\t- Contain at least a number;')
14+
print('\t- Contain at least a special character (such as @,+,£,$,%,*^,etc);')
15+
print('\t- Not contain space(s).')
16+
# get user's password
17+
userPassword = input('\nEnter a valid password: ').strip()
18+
# check if user's password conforms
19+
# to the rules above
20+
if not(6 <= len(userPassword) <= 12):
21+
message = 'Invalid Password..your password should have a minimum '
22+
message += 'length of 6 and a maximum length of 12'
23+
return message
24+
if ' ' in userPassword:
25+
message = 'Invalid Password..your password shouldn\'t contain space(s)'
26+
return message
27+
if not any(i in string.ascii_letters for i in userPassword):
28+
message = 'Invalid Password..your password should contain at least '
29+
message += 'an uppercase letter and a lowercase letter'
30+
return message
31+
if not any(i in string.digits for i in userPassword):
32+
message = 'Invalid Password..your password should contain at least a number'
33+
return message
34+
if not any(i in string.punctuation for i in userPassword):
35+
message = 'Invalid Password..your password should contain at least a special character'
36+
return message
37+
else:
38+
return 'Valid Password!'
39+
40+
my_password = passwordValidator()
41+
print(my_password)

Password Validator/screenshot_1.png

35 KB
Loading

Password Validator/screenshot_2.png

37.8 KB
Loading

Password Validator/screenshot_3.png

32.4 KB
Loading

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ This is a collection of short Python scripts to solve and automate tasks and sim
5353
32 | [**JSON-YAML**](https://github.com/decipher07/Useful-Python-scripts-collection/blob/master/JSON-YAML) | A Python script which converts JSON To YAML and Vice-Versa | JSON, YAML |
5454
33 | [**CSV_to_JSON**](https://github.com/TechBoyy6/Python-scripts-collection/tree/master/CSV_to_JSON) | A script that converts the csv file into json file. | None |
5555
34 | [**SMS-SENDER**](https://github.com/CopyrightC/Python-scripts-collection/blob/master/SMS_SENDER/main.py) | A python script that uses Tkinter and Twilio to send SMS. | twilio|
56+
35 | [**Password Validator**](https://github.com/Mannuel25/Python-scripts-collection/tree/master/Password%20Validator) | A script validates passwords to match specific rules. A valid password is one that conforms to some specific rules. | None |

0 commit comments

Comments
 (0)