Created
January 20, 2018 22:49
-
-
Save macostag/df0f1a1b1b860d04e08f4affbbd61aac to your computer and use it in GitHub Desktop.
Decrypt 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 decrypt3DES(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.decrypt(data) | |
return encrypted | |
encryptionKey = INSERT ENCRYPTION KEY | |
print "Key (HEX Value):: " | |
print encryptionKey.upper() | |
encryptedData = INSERT ENCRYPTED DATA | |
print "Encrypted Data (HEX Value):: " | |
print encryptedData.upper() | |
print "" | |
outputData = decrypt3DES(encryptionKey,encryptedData) | |
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