[pycrypto] ARC4 examples

Dave Pawson dave.pawson at gmail.com
Sun Nov 17 03:16:40 PST 2013


https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.ARC4-module.html#new

from which

>>> from Crypto.Cipher import ARC4
>>> from Crypto.Hash import SHA
>>> from Crypto import Random
>>>
>>> key = b'Very long and confidential key'
>>> nonce = Random.new().read(16)
>>> tempkey = SHA.new(key+nonce).digest()
>>> cipher = ARC4.new(tempkey)
>>> msg = nonce + cipher.encrypt(b'Open the pod bay doors, HAL')

I cannot get that to decrypt to the plaintext.
What is the point of adding the nonce to the ciphertext please, and
how to decrypt?

TiA


-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk


More information about the pycrypto mailing list