Python and PHP encryption/decryption

J

Jean-Claude Neveu

I'm looking for a recommendation about encryption/decryption packages
for Python.

I'm working on a project that will require me to store some values in
a database in encrypted format. I'll be storing them from a PHP
script and retrieving them (decrypting them) using Python. I'm
currently using PHP's mcrypt package to encrypt the values, and I'm
using AES for encryption, so something AES-compatible would be ideal.
However, the project is at the development stage so I can easily
change how I'm encrypting things in PHP if there is a compelling
reason on the Python side of things to do so.

Many Thanks,
Jean-Claude
 
D

Diez B. Roggisch

Jean-Claude Neveu said:
I'm looking for a recommendation about encryption/decryption packages
for Python.

I'm working on a project that will require me to store some values in a
database in encrypted format. I'll be storing them from a PHP script and
retrieving them (decrypting them) using Python. I'm currently using
PHP's mcrypt package to encrypt the values, and I'm using AES for
encryption, so something AES-compatible would be ideal. However, the
project is at the development stage so I can easily change how I'm
encrypting things in PHP if there is a compelling reason on the Python
side of things to do so.

With PyCrypto[1] you have a wide range of choices, amongst others AES.

If that's the best algorithm, or even the best python-package to
implement it, I don't know.


[1] http://www.dlitz.net/software/pycrypto/


Diez
 
P

Paul Rubin

Jean-Claude Neveu said:
I'm working on a project that will require me to store some values in
a database in encrypted format. I'll be storing them from a PHP script
and retrieving them (decrypting them) using Python. I'm currently
using PHP's mcrypt package to encrypt the values, and I'm using AES
for encryption, so something AES-compatible would be ideal.

There are several python libraries that support AES in the standard
operating modes. If you are doing something sensible on the PHP side,
you should be able to get Python to interoperate with it. Be careful
that you are doing the right things algorithmically in terms of modes,
IV's, etc. If you don't know what you're doing in this area, it's
best to (at minimum) seek more specific advice.
 
P

Piet van Oostrum

DBR> With PyCrypto[1] you have a wide range of choices, amongst others AES.
DBR> If that's the best algorithm, or even the best python-package to implement
DBR> it, I don't know.

DBR> [1] http://www.dlitz.net/software/pycrypto/

Pycrypto had been stalled in development. The latest release was in
2005. There is now a new developer and that it were the link above goes,
but he has not yet released anything. so you will have to do with the
2005 release.

There is an alternative library: m2crypto
(http://chandlerproject.org/Projects/MeTooCrypto). It is built on top of
OpenSSL which is available for most platforms that have Python whereas
Pycrypto has its own C implementations of crypto algorithms. M2crypto
has a recent release. Also I think because OpenSSL is widely used, its
vulnerabilities are easier detected and corrected, whereas I don't think
that is the case for Pycrypto.

M2crypto is much bigger than you need for this project, however. If that
doesn't bother you I would recommend it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top