-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Federico
committed
Jun 17, 2023
1 parent
6578e66
commit 9f703e8
Showing
2 changed files
with
100,025 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
def check_password(password: str): | ||
"""Checks whether a password is in the 100.000 most common passwords.""" | ||
|
||
# Open up the file with most common passwords | ||
with open('passwords.text', 'r') as file: | ||
common_passwords: list[str] = file.read().splitlines() | ||
|
||
# If any of the words are equal to the password, return True | ||
for i, common_password in enumerate(common_passwords, start=1): | ||
if password == common_password: | ||
print(f'{password}: ❌ (#{i})') | ||
return # Exit the function as soon as we have a match | ||
|
||
# If the password is not located in the common passwords, it's unique | ||
print(f'{password}: ✅ (Unique)') | ||
|
||
|
||
def main(): | ||
# Check password | ||
user_password: str = input('Enter a password: ') | ||
check_password(password=user_password) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.