-
-
Save add1ct3d/7b87653de908c479b59b4adeaa55f77c to your computer and use it in GitHub Desktop.
python DES3(triple DES encryption)
This file contains hidden or 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
| `pip install pycrypto` | |
| from Crypto.Cipher import DES3 | |
| from Crypto import Random | |
| key = 'Sixteen byte key' | |
| iv = Random.new().read(DES3.block_size) #DES3.block_size==8 | |
| cipher_encrypt = DES3.new(key, DES3.MODE_OFB, iv) | |
| plaintext = 'sona si latine loqueri ' #padded with spaces so than len(plaintext) is multiple of 8 | |
| encrypted_text = cipher_encrypt.encrypt(plaintext) | |
| cipher_decrypt = DES3.new(key, DES3.MODE_OFB, iv) #you can't reuse an object for encrypting or decrypting other data with the same key. | |
| cipher_decrypt.decrypt(encrypted_text) | |
| cipher_decrypt.decrypt(encrypted_text) #you cant do it twice |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment