0

When I am trying to convert to hex the output of my AES 128 encryption code using pycrypto. I am using hexlify .the output is 64 bits for a 32 bits input. The output is always double the size for any input and when use an online compiler I get a perfect 32 bit output.Whats the wrong

What format should i convert the data to get the same size as the input while implementing it.

text= 3235383334332b352b3934363230383037312b3100000000

key ='0123456789abcdef'

iv = '/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00'

encryptor = AES.new(key,mode,IV=iv)

output=encryptor.encrypt(text)

I get encrypted output as

?"?χ?v???
         ؛?3(???nyA??U?}??/??>

I wanted to convert it into a format where i could read it hence was converting it hex

efb82283cf87e7127696baad0c1bd89b3781331c289db9f96e7941d3cd55c77db8a72fdcdd3e1ac1bc9031c61c998e49

can you suggest some other readable format to which i could convert my data to??

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • Please provide some code that demonstates your problem, example inputs, outputs and expected outputs. – Artjom B. Jul 20 '15 at 19:55
  • Why does it have to be the same size? Hex would be the standard for making it readable. A lot better than binary or octal. – mikeazo Jul 21 '15 at 18:55

1 Answers1

1

I quote from the python documentation for binascii.hexlify (emphasis added):

Return the hexadecimal representation of the binary data. Every byte of data is converted into the corresponding 2-digit hex representation. The resulting string is therefore twice as long as the length of data.

 

What format should i convert the data to get the same size as the input while implementing it.

Don't convert it at all. Just write it as binary data.

mikeazo
  • 389
  • 2
  • 24