了解pycrypto示例

时间:2017-04-26 01:45:32

标签: python encryption aes pycrypto

     As an example, encryption can be done as follows:

    >>> from Crypto.Cipher import AES
    >>> from Crypto import Random
    >>>
    >>> key = b'Sixteen byte key'
    >>> iv = Random.new().read(AES.block_size)
    >>> cipher = AES.new(key, AES.MODE_CFB, iv)
    >>> msg = iv + cipher.encrypt(b'Attack at dawn')

当我在我收到的口译员上执行'msg'时

    b'D\x9e\nRF\xb9\xe3\xa0%vN\xe8bC\xe7\r8\xec\xae\x84\x9b\xf9\x11\xdc\xdf\xcb\xf4\xfev\x9b'   

据我所知,这是'key'变量,是字节形式的'十六字节键'。

现在'msg'已加密,我该怎么做才能解密此消息?

0 个答案:

没有答案