How can I encrypt and decrypt hex text using 8 byte hex key using DES algorithm in python?
I have a hex text 0x3a3456abcd4ff5cd
to encrypt with hex keys so how can I convert these values to equivalent strings so that I can use existing libraries to work with them.
Here's what I've tried, but it represents 8 byte key to equivalent 13 byte string:
from Crypto.Cipher import DES
text =(unichr(4).decode('utf-8')*8).encode('utf-8')
key1=(unichr(0x46)+unichr(0xb2)+unichr(0xc8)+unichr(0xb6)+unichr(0x28)+unichr(0x18)+unichr(0xf8)+unichr(0x84)).encode('utf-8')
key2=(unichr(0x4a)+unichr(0x5a)+unichr(0xa8)+unichr(0xd0)+unichr(0xba)+unichr(0x30)+unichr(0x58)+unichr(0x5a)).encode('utf-8')
des = DES.new(key1,DES.MODE_ECB)
cipher_text = des.encrypt(plain_text)
print 'the cipher text is ', cipher_text
des = DES.new(key2,DES.MODE_ECB)
print 'the decrypted text is: ', des.decrypt(cipher_text)