Created
January 28, 2013 08:58
-
-
Save bngsudheer/4654029 to your computer and use it in GitHub Desktop.
Encrypt and decrypt using DES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Encrpyt the string 'abcdefghijklmnop' | |
from Crypto.Cipher import DES | |
from Crypto import Random | |
iv = Random.get_random_bytes(8) | |
des1 = DES.new('issecret', DES.MODE_CFB, iv) | |
text = 'abcdefghijklmnop' | |
cipher_text = des1.encrypt(text) | |
print cipher_text | |
# Decrpyt the cipher text | |
des2 = DES.new('issecret', DES.MODE_ECB) | |
print des2.decrypt(cipher_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment