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


Groups > comp.lang.python > #7117

Re: python + php encrypt/decrypt

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'padding': 0.09; 'pm,': 0.10; 'wrote:': 0.14; 'subject:python': 0.14; 'library': 0.15; 'def.': 0.16; 'docs,': 0.16; 'lambda': 0.16; 'pad': 0.16; 'url:trunk': 0.16; '16,': 0.16; 'cc:addr:python-list': 0.17; 'mon,': 0.17; 'url:code': 0.17; 'cheers,': 0.19; 'header:In-Reply- To:1': 0.21; 'cc:2**0': 0.22; 'maybe': 0.23; 'cc:no real name:2**0': 0.23; 'trying': 0.23; 'here?': 0.23; 'received:209.85.161.46': 0.23; 'received:mail- fx0-f46.google.com': 0.23; 'appear': 0.23; "doesn't": 0.25; 'received:209.85.161': 0.26; 'times.': 0.26; 'message- id:@mail.gmail.com': 0.28; '24,': 0.29; 'cc:addr:python.org': 0.30; 'subject: + ': 0.30; 'skip:b 30': 0.31; 'url:library': 0.31; 'agree': 0.32; 'does': 0.33; 'php': 0.34; 'couple': 0.35; 'url:source': 0.36; 'subject:/': 0.36; 'probably': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'url:google': 0.38; 'explain': 0.39; 'doing': 0.39; 'should': 0.39; 'received:209': 0.39; 'really': 0.40; 'worth': 0.60; 'here:': 0.62; 'according': 0.63; 'url:p': 0.63; 'note:': 0.63; 'url:20': 0.67; 'url:r': 0.78; 'url:php': 0.81; 'cbc': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=SdMWNR97ZpXRoj01/KNzRToTvuvUmk5PaJ/Wsz4PPiM=; b=xEtdZGQw0soOvjsQE4WuO1uxgbTMIJhLkDVZoW9dtiKAuFZ3+m6gd3yngqmDAClaMj ox2CT0BLVPxDWkPdX7A8/8lY+CNuc4LgOca6Zngg0VEJClxd9PQMtdDSKxhxX4mRgtsc F32MAgkgTJ6h1uNXrjSqtxaJU41kdf8fu7Bcs=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=b5DbqpG8pJc+udY2SuC2FzkX6aKvody0d0Fphx5py+sIZX1WyM4PReE48R4vuScazy dgMVEFmzqXg60r9XVmzIe7IGZCJJHv8u2dTDjw1tHLXkcs/UKeKaS75wCaygCS9M9cYp L1C6sTH/eVYacVBJurWIQqe1+jR6+ZGq+XNwo=
MIME-Version 1.0
In-Reply-To <0a8faeca-4c26-490b-9676-ebe8e3b1c930@l6g2000vbn.googlegroups.com>
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 Mon, 6 Jun 2011 17:45:35 -0600
Subject Re: python + php encrypt/decrypt
To miamia <peterirbizon@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2510.1307403967.9059.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 82.94.164.166
X-Trace 1307403967 news.xs4all.nl 49047 [::ffff:82.94.164.166]:57544
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7117

Show key headers only | 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