[pycrypto] Public Key encryption of files

Dave Pawson dave.pawson at gmail.com
Thu Nov 10 12:26:52 CST 2011

On 10 November 2011 18:18, Dean Macinskas <dmacinskas at geobridge.net> wrote:
> All blocks need to be 16 bytes.  So for example, if the file is 2,000,005
> bytes, you'd encrypt 125,000 16-byte blocks; you then have 5 bytes left
> over, to which you'd add 11 padding bytes, which can be any binary value and
> then encrypt that last block.

def _lazysecret(secret, blocksize=32, padding='}'):
    """pads secret if not legal AES block size (16, 24, 32)"""
    if not len(secret) in (16, 24, 32):
        return secret + (blocksize - len(secret)) * padding
    return secret

Python makes it quite easy.
  The reason I started to use it!
Thanks to
src http://www.turnkeylinux.org/blog/python-symmetric-encryption

great piece of software.


Dave Pawson
Docbook FAQ.

More information about the pycrypto mailing list