Skip to content

Instantly share code, notes, and snippets.

@macostag
Created January 20, 2018 22:49
Show Gist options
  • Save macostag/df0f1a1b1b860d04e08f4affbbd61aac to your computer and use it in GitHub Desktop.
Save macostag/df0f1a1b1b860d04e08f4affbbd61aac to your computer and use it in GitHub Desktop.
Decrypt hex strings using 3DES (ECB mode).
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