0
我試圖在Python中實現Blowfish算法。我認爲我對算法有一個相當普遍的理解,但是一些實現細節正在失去我。Blowfish密碼 - 按位異或與P數組的密鑰
該算法包括的十六進制數
#Note: I shortened the 18 element array for this example
PI_P_ARRAY = (0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344)
和祕密密鑰
key = 'mysecret'
維基百科「,該祕密密鑰是,逐字節的數組,循環密鑰必要時,異或同所有的P條目順序。「我如何在Python中實現這個?
到目前爲止,我甚至無法將密鑰轉換爲十六進制!更何況週期它變成一個十六進制數組,我可以用P-陣列XOR ...
#Failed attempts to convert key to hex
import binascii
binascii.hexlify(key)
key.encode('hex')
bytearray(key)