-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
26 lines (21 loc) · 802 Bytes
/
main.py
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
import base64
def encrypt(text):
encrypted_text = base64.b64encode(text.encode()).decode()
return encrypted_text
def decrypt(encrypted_text):
decrypted_text = base64.b64decode(encrypted_text.encode()).decode()
return decrypted_text
def main():
choice = input("Enter 'e' to encrypt a message, 'd' to decrypt an encrypted message: ")
if choice == 'e':
text = input("Enter the text: ")
encrypted_text = encrypt(text)
print("Encrypted text:", encrypted_text)
elif choice == 'd':
encrypted_text = input("Enter the encrypted text: ")
decrypted_text = decrypt(encrypted_text)
print("Decrypted text:", decrypted_text)
else:
print("Invalid choice.")
if __name__ == "__main__":
main()