With just about everybody snooping around your emails today with the excuse of hunting the bad guys, coding to keep some resemblance of privacy is getting important. I will start out with some simple encryption examples to get this started. You are invited to give us your thoughts and codes. Hopefully, we can improve the code as time goes on.
The first example is very simplistic form of a Caesar cipher, simply increasing the ASCII values by one to encrypt and decreasing by one to decrypt. It would be easy to figure that scheme out by looking at the letter frequency. In the English language the most common letter is 'e' and suddenly it would be the next ASCII character 'f'. So, even a challenged snoop could see through that after a while.
''' encrypt101.py
simple shift ASCII value by one encryption/decryption
however simple to crack by analyzing the letter frequency pattern
'''
def encrypt101(text):
'''
shift ASCII values of text up by one
'''
return "".join(chr(ord(c) + 1) for c in text)
def decrypt101(e_text):
'''
shift ASCII values of text down by one
'''
return "".join(chr(ord(c) - 1) for c in e_text)
text = "Facebook or Twitter make privacy a thing of the past"
encrypted = encrypt101(text)
print("encrypted = {}".format(encrypted))
print('-'*50)
decrypted = decrypt101(encrypted)
print("decrypted = {}".format(decrypted))
''' my result ...
encrypted = Gbdfcppl!ps!Uxjuufs!nblf!qsjwbdz!b!uijoh!pg!uif!qbtu
--------------------------------------------------
decrypted = Facebook or Twitter make privacy a thing of the past
'''
This type of code does not need a password, but the user has to have this program available.