Skip to content

Commit 56b02e8

Browse files
committed
Yet another password strength checker
1 parent ce48c83 commit 56b02e8

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

password_generator/pw_checker.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# coding=utf-8
2+
# Author: Vitor Ribeiro
3+
4+
#This a program to check the security of passwords.
5+
6+
# Passwords must be at least 8 characters long.
7+
# Passwords must contain at least one uppercase letter and one number.
8+
9+
import re, pyperclip
10+
11+
# First you need to copy your password to the clipboard, the program will do the rest.
12+
13+
password = pyperclip.paste()
14+
15+
eightLettersRegex = re.compile(r'\S{8,}')
16+
17+
oneUppercaseRegex = re.compile(r'[A-Z]')
18+
19+
oneNumberRegex = re.compile(r'\d')
20+
21+
check = {
22+
eightLettersRegex: 'Your password must be 8 letters',
23+
oneUppercaseRegex: 'Your password must have at least one uppercase Letter.',
24+
oneNumberRegex: 'Your password must have at least one number.'
25+
}
26+
27+
print('Analyzing your password.')
28+
29+
count = 1
30+
for regex, msg in check.items():
31+
mo = regex.search(password)
32+
if mo == None:
33+
print(msg)
34+
break
35+
if count == len(check):
36+
print('Good! Your password is strong enough!')
37+
count += 1
38+
39+
print('End.')

0 commit comments

Comments
 (0)