I need to encrypt a message using a secret key and return the message. I tried this and I got the correct output.
def my_encryption(some_string):
character_set= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "
secret_key=" Dd18Abz2EqNPW hYTOjBvtVlpXaH6msFUICg4o0KZwJeryQx3f9kSinRu5L7cGM"
m=some_string
k=m.translate({ord(x): y for (x, y) in zip(character_set,secret_key )})
return m
print(my_encryption("Lets meet at the usual place at 9 am"))
The output I got is
oABjMWAABMDBMB2AMvjvDPMYPD1AMDBMGMDWB
and this is correct. I would like to know, will there be any other way to do this with out using translate?. I am curious to know the alternate ways. I will be glad to know. Thank you.