encrypt and decrypt

Job ID: 34751676

Budget: $10 – $30 USD

i need my project to encrypt and decrypt inputs and to return certain things for invalid inputs

this is the code i currently have:

def encrypt(M,k):
M_result = ''
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '
for x in M:
if x in alphabet:
M_result += alphabet[(alphabet.find(x) + k)%27]
elif x not in alphabet and k != int:
print('0')
break
elif x not in alphabet:
print('1')
break
elif k != int:
print('2')
break

return M_result


def decrypt(M,k):
M_result = ''
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '
for x in M:
if x in alphabet:
M_result += alphabet[(alphabet.find(x) - k)%27]
elif x not in alphabet and k != int:
print('0')
break
elif x not in alphabet:
print('1')
break
elif k != int:
print('2')
break
Related categories: Python Encryption