Wednesday, November 3, 2010

Simple encryption (part2- Decryption)

In the last post, Simple encryption in Python, we discussed a simple way to use ASCII characters for encryption. If you haven't read that post I recommend that you do so before moving on.

In this post we will discuss how to decrypt the text we encrypted in the last post. The basic idea here is just to reverse the process we followed while encrypting.

text_enc_char=input('Enter encrypted text:')
enc_factor=200
for encchar in text_enc_char:
                dec_char=ord(encchar)+enc_factor
                text_dec+=chr(dec_char)

print(text_dec)