Skip to content

Commit

Permalink
Added common password project
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico committed Jun 17, 2023
1 parent 6578e66 commit 9f703e8
Show file tree
Hide file tree
Showing 2 changed files with 100,025 additions and 0 deletions.
25 changes: 25 additions & 0 deletions starter_projects/common_password/main.py
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()
Loading

0 comments on commit 9f703e8

Please sign in to comment.