Created
January 20, 2018 22:45
-
-
Save macostag/98f370fbf16b473cd78cacd6893c8270 to your computer and use it in GitHub Desktop.
Encrypt hex strings using 3DES (ECB mode).
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
import binascii | |
import random | |
import hashlib | |
import base64 | |
from pyDes import * | |
def encrypt3DES(skey,sdata): | |
key = binascii.unhexlify(skey) | |
data = binascii.unhexlify(sdata) | |
key3DES = triple_des(key, ECB, "\0\0\0\0\0\0\0\0", pad=None, padmode=PAD_NORMAL) | |
encrypted = key3DES.encrypt(data) | |
return encrypted | |
encryptionKey = INSERT ENCRYPTION KEY | |
print "Key (HEX Value):: " | |
print encryptionKey.upper() | |
inputData = INSERT INPUT DATA | |
print "Input Data (HEX Value):: " | |
print inputData.upper() | |
print "" | |
outputData = encrypt3DES(encryptionKey,inputData) | |
print "Output Data (HEX Value):: " | |
print str(binascii.hexlify(outputData)).upper() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment