-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasswordEncoder.py
More file actions
44 lines (39 loc) · 1.43 KB
/
passwordEncoder.py
File metadata and controls
44 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Adnan Sanaulla and Jake Marotta
def encode(password):
encoded_password = ""
for char in password:
encoded_char = (int(char) + 3) % 10
encoded_password += str(encoded_char)
return encoded_password
def decode(password):
decoded_password = ""
for char in password:
decoded_char = (int(char) - 3) % 10
decoded_password += str(decoded_char)
return decoded_password
def main():
while True:
print("\nMenu:")
print("1. Encode Password")
print("2. Decode Password")
print("3. Quit")
choice = input("Enter your choice (1-3): ")
if choice == "1":
password = input("Enter an 8-digit password (integers only): ")
if len(password) == 8 and password.isdigit():
encoded_password = encode(password)
print("Encoded Password:", encoded_password)
else:
print("Invalid password. Please enter an 8-digit integer.")
elif choice == "2":
password = input("Enter an 8-digit encoded password (integers only): ")
if len(password) == 8 and password.isdigit():
decoded_password = decode(password)
print("Decoded Password:", decoded_password)
elif choice == "3":
print("Goodbye!")
break
else:
print("Invalid choice. Please select again.")
if __name__ == "__main__":
main()