Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions encrypt-decrypt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
count = 0
while True:
userName = input("\n\nUsername: ")
from getpass import getpass
password =getpass()
count += 1
if count == 3:
print("Bye!");
break #The program stops when the user enters the wrong username or password three times
else:
# Change your password and Username
if userName == 'ap' and password == '1234':

decrypted = b"abcdefghijklmnopqrstuvwxyz!@#$%^&*()1234567890 "
# your own encryption methode
# Importent : Do not write one charactor multiple times
encrypted = b"qmlpoknjiuhbvgytfcxdreszaw3465217809(@)!#*^$%& "

encrypt_table = bytes.maketrans(decrypted, encrypted)
decrypt_table = bytes.maketrans(encrypted, decrypted)


result = ''
choice = ''
message = ''

while choice != '3':
choice = input("---------------------------------------------------"
"\n Do you want to encrypt or decrypt the message?\n"
" 1. encrypt\n 2. decrypt\n 3. exit program.\n\nchoose: ")
# encryption process
if choice == '1':
message = input('\nEnter message for encryption: ')
result = message.translate(encrypt_table)
print("\n==> " + result + '\n')

# decryption process
elif choice == '2':
message = input('\nEnter message to decrypt: ')
result = message.translate(decrypt_table)
print("\n==> " + result + '\n')

elif choice != '3':
print('\n\nIncorrect Choice! \n')
break