Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7117

Re: python + php encrypt/decrypt

References <BANLkTi=dvEzU1OoCMoUMQcOjR-S6cgMX5Q@mail.gmail.com> <20cf307d01dce685d304a4de3dc5@google.com> <BANLkTin5BxqDPC2GsR+_eHuQjfPg6bJ5gA@mail.gmail.com> <mailman.2497.1307382091.9059.python-list@python.org> <0a8faeca-4c26-490b-9676-ebe8e3b1c930@l6g2000vbn.googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2011-06-06 17:45 -0600
Subject Re: python + php encrypt/decrypt
Newsgroups comp.lang.python
Message-ID <mailman.2510.1307403967.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jun 6, 2011 at 4:19 PM, miamia <peterirbizon@gmail.com> wrote:
> php I am trying to use is here:
> http://code.google.com/p/antares4pymes/source/browse/trunk/library/System/Crypt/AES.php?r=20

That library does not appear to be doing CBC as far as I can tell.
Maybe they will agree if you use EBC instead?

> BLOCK_SIZE = 32

According to the docs, the block size for AES is 16, not 32.  It is
the key size that can be 16, 24, or 32.  But this should just result
in extra padding, so it probably doesn't explain the discrepancy.

> pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * PADDING
> EncodeAES = lambda c, s: base64.b64encode(c.encrypt(pad(s)))
> DecodeAES = lambda c, e:
> c.decrypt(base64.b64decode(e)).rstrip(PADDING)

Stylistic note: is it really necessary to use lambda here?  For
readability, just use def.  It's worth having to hit Enter a couple
extra times.

Cheers,
Ian

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: python + php encrypt/decrypt geremy condra <debatem1@gmail.com> - 2011-06-06 10:41 -0700
  Re: python + php encrypt/decrypt miamia <peterirbizon@gmail.com> - 2011-06-06 15:19 -0700
    Re: python + php encrypt/decrypt Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-06 17:45 -0600

csiph-web