Is there a simple way to encrypt/decrypt a string with a key?
Something like:
key = \'1234\'
string = \'hello world\'
encrypted_string = encrypt(key, st
pyDES is a DES and Triple-DES implementation completely written in python.
Here's a simple and portable example that should be secure enough for basic string encryption needs. Just put the pyDES module in the same folder as your program and try it out:
Sender's computer
>>> from pyDES import * # pyDes if installed from pip
>>> ciphertext = triple_des('a 16 or 24 byte password').encrypt("secret message", padmode=2) #plain-text usually needs padding, but padmode = 2 handles that automatically
>>> ciphertext
')\xd8\xbfFn#EY\xcbiH\xfa\x18\xb4\xf7\xa2' #gibberish
Recipient's computer
>>> from pyDES import *
>>> plain_text = triple_des('a 16 or 24 byte password').decrypt(')\xd8\xbfFn#EY\xcbiH\xfa\x18\xb4\xf7\xa2', padmode=2)
>>> plain_text
"secret message"