Different Results in Go and Pycrypto when using AES-CFB

前端 未结 5 1147
遇见更好的自我
遇见更好的自我 2021-01-02 05:33

I am adding a go application to an already existing python codebase. I\'ve been having trouble dealing with encryption between the languages. This is using go 1.2.1 and Pyth

5条回答
  •  悲哀的现实
    2021-01-02 05:44

    It seems that the cipher can be made compatible to Go's crypto/cipher if we change segment_size of AES object from the default 8 to AES.block_size*8 (which is 128), like this:

    Crypto.Cipher.AES.new(
                key=password, 
                mode=Crypto.Cipher.AES.MODE_CFB, 
                IV=iv,
                segment_size=AES.block_size*8
    )
    

提交回复
热议问题