0

I try to encrypt all zeros using the crypto library. However, after I do the decode, the value is gone. How can I get the ASCII value after the decode hex?

from Crypto.Cipher import AES
#..
#.. cipher initialization
#..

ctr_a = ctr.decode("hex") #hex coded string to hex string
print ctr
print ctr_a
temp = obj.encrypt(str(ctr_a))

output

ctr = 00000000000000000000000000000000
ctr_a = 

1 Answer 1

1

It's not empty, it's just that 00 is a null character which displays nothing in a terminal

ctr = "00000000000000000000000000000000"
ctr_a = ctr.decode("hex") #hex coded string to hex string
print ctr
print len(ctr_a)

returns

00000000000000000000000000000000
16

If you change one of the sets to a character that will render to the screen you will see the difference

ctr = "00650000000000000000000000000000"
ctr_a = ctr.decode("hex") #hex coded string to hex string
print ctr
print len(ctr_a)
print '"%s"' % ctr_a

outputs

00650000000000000000000000000000
16
"e"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.