[pycrypto] Public Key encryption of files

Dean Macinskas dmacinskas at geobridge.net
Thu Nov 10 13:28:54 CST 2011


Dave,

An AES key can be 16, 24 or 32 bytes, but the data block size for AES is 16 bytes, regardless of key length.

Dean


-----Original Message-----
From: pycrypto-bounces at lists.dlitz.net [mailto:pycrypto-bounces at lists.dlitz.net] On Behalf Of Dave Pawson
Sent: Thursday, November 10, 2011 1:27 PM
To: PyCrypto discussion list
Subject: Re: [pycrypto] Public Key encryption of files

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.

regards



-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
_______________________________________________
pycrypto mailing list
pycrypto at lists.dlitz.net
http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto


More information about the pycrypto mailing list