[pycrypto] checksum problem.
Dave Pawson
dave.pawson at gmail.com
Thu Sep 1 03:46:58 CST 2011
I've been ignoring a checksum error for some time now, and decided to
ask for help.
Workaround
def decrypt(ciphertext, secret, lazy=True, checksum=True):
"""decrypt ciphertext with secret
ciphertext - encrypted content to decrypt
secret - secret to decrypt ciphertext
lazy - pad secret if less than legal blocksize (default: True)
checksum - verify crc32 byte encoded checksum (default: True)
returns plaintext
"""
secret = _lazysecret(secret) if lazy else secret
encobj = AES.new(secret, AES.MODE_CFB)
plaintext = encobj.decrypt(ciphertext)
if checksum:
crc, plaintext = (plaintext[-4:], plaintext[:-4])
if not crc == struct.pack("i", zlib.crc32(plaintext)):
print "Checksum error"
#raise CheckSumError("checksum mismatch")
return plaintext
1. I'm not sure how its happening or what I can do to resolve it?
Currently working on windows.
Reading the file using binary mode
Ditto writing.
I'm creating a plain text file,
encrypting
then writing back to disk
Access then reads the file, decrypts and returns the sought string.
The checksum error is showing in the decrypt fn above.
Any help appreciated.
--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
More information about the pycrypto
mailing list