python解码('十六进制')返回空ASCII字符串

问题描述:

我尝试使用加密库加密所有零。但是,在我解码之后,价值就没有了。如何在解码十六进制后获取ASCII值?python解码('十六进制')返回空ASCII字符串

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)) 

输出

ctr = 00000000000000000000000000000000 
ctr_a = 

它不是空的,它只是00一个是空字符,显示没有在终端

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

回报

00000000000000000000000000000000 
16 

如果您将其中一组更改为cha racter将呈现到屏幕上,你会看到其中的差别

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

输出

00650000000000000000000000000000 
16 
"e"