2015-02-08 59 views
0

我嘗試使用加密庫加密所有零。但是,在我解碼之後,價值就沒有了。如何在解碼十六進制後獲取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 = 

回答

1

它不是空的,它只是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" 
相關問題