我在这里找到了 atomicinf 的以下代码:atomicinf 的代码!代码是:
import Crypto.Cipher.AES
import Crypto.Util.Counter
key = "0123456789ABCDEF" # replace this with a sensible value, preferably the output of a hash
iv = "0000000000009001" # replace this with a RANDOMLY GENERATED VALUE, and send this with the ciphertext!
plaintext = "Attack at dawn" # replace with your actual plaintext
ctr = Crypto.Util.Counter.new(128, initial_value=long(iv.encode("hex"), 16))
cipher = Crypto.Cipher.AES.new(key, Crypto.Cipher.AES.MODE_CTR, counter=ctr)
print cipher.encrypt(plaintext)
我的问题是:解密是如何工作的?(显然我必须手动导入计数器或将当前计数器保存在某处)第二个 DES 呢?我知道它有较小的计数器,但我如何定义它?