I read somewhere that other people read your mail. People that are using gmail reports that that they seems to get ads related to their mails, so perhaps Google reads it! After reading this, panic and paranoia strikes, and you wonder, what could I do about this?
What could we do in Python? First I want to add a message, then I want to encrypt it, send it with gmail, and then I would like to be able to decrypt it afterwards.
After coding this, you can't help thinking, "why would somebody read my emails in the first place? What do I have to hide?"
What could we do in Python? First I want to add a message, then I want to encrypt it, send it with gmail, and then I would like to be able to decrypt it afterwards.
Code:
import smtplib,math
from Crypto.Cipher import DES
message = """
this is a secret message send from bytes.com
-kudos
"""
# need to be divisible by 8 so we add extra ' '
v = len(message) / 8.0
w = int(math.ceil(v) * 8.0)
for i in range(w-len(message)):
message = message+" "
# here we add a key to encrypt the message, which we choose to be "thebytes"
des = DES.new('thebytes', DES.MODE_ECB)
crypted = des.encrypt(message)
# create a string which will be easier to decode from mail
s=""
for x in crypted:
s+=str(ord(x))+"#"
s = s[0:len(s)-1] # remove the last '#'
# try to decode it, normally you would insert content from a mail
s2=""
for b in s.split("#"):
s2+=chr(int(b))
print des.decrypt(s2)
# now, mail it with gmail
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login("your gmail username","your gmail password")
server.sendmail("to address", "fron address", s)
server.quit()
Comment