473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Encryption between Python & PHP

Hi folks,

I am looking for a practical way of sending encrypted strings back and
forth between a Python HTTP client on Windoze and an Apache/PHP server
on Linux. I am looking for a simple, lightweight symmetrical solution
using, say, blowfish: SSL would be a last resort as I suspect it will
cause fairly major installation issues on the client.

Encryption in PHP uses a wrapper around the mcrypt C library.

There is a wrapper for mcrypt in Python, but I am having trouble
getting it installed on Windows: I have contacted the author for help.

Meanwhile, I do have SSLcrypto installed: this is a very neat and fast
library. Is there any way for SSLcrypto on Python to talk to mcrypt on
PHP? My first attempts have been unsuccessful.

I have little crypto knowledge, and at first I though that something
like blowfish was a standard and different libraries should be
compatible. Now I suspect that internal implementation varies between
libraries and you have to encrypt/decrypt with the same library. Can
anyone enlighten me?

------------------
Geoff Caplan
Vario Software Ltd
(+44) 121-515 1154

Jul 18 '05 #1
4 2972
On Sun, 8 Aug 2004 14:00:32 +0100,
Geoff Caplan <ge***@variosoft.com> wrote:
I have little crypto knowledge, and at first I though that something
like blowfish was a standard and different libraries should be
compatible. Now I suspect that internal implementation varies between
libraries and you have to encrypt/decrypt with the same library. Can
anyone enlighten me?


I can't help much with your other questions, but I do know about this
one. By definition, blowfish is blowfish is blowfish. Any (properly
implemented) blowfish library will be compatible with another; if you
encode something with one library, you will be able to decode it with
the other. It is up to you to use the same key and to make sense of the
information once you decrypt it.

That said, yes, it is possible that the internal implementation details
may vary slightly between libraries, but not in ways that the user will
notice. Think of this like calculators: although calculators use
different hardware and different display devices, they all (should) give
the same answer to the same multiplication problem (keeping the
multiplications in question simple enough so as not to cause some sort
of underflow or overflow error or loss of precision; thankfully,
blowfish implementations do not suffer even this limitation).

HTH,
Dan

--
Dan Sommers
<http://www.tombstonezero.net/dan/>
Never play leapfrog with a unicorn.
Jul 18 '05 #2
Dan,

DS> I can't help much with your other questions, but I do know about this
DS> one. By definition, blowfish is blowfish is blowfish. Any (properly
DS> implemented) blowfish library will be compatible with another; if you
DS> encode something with one library, you will be able to decode it with
DS> the other.

Thanks for that. Looks like I should persist and track down the
problem. Perhaps something to do with the keys? When I try to
decrypt I am getting binary garbage out instead of an ascii string.

Any pointers about where to start looking would be welcome!
------------------
Geoff Caplan
Vario Software Ltd
(+44) 121-515 1154

Jul 18 '05 #3
On Sun, 8 Aug 2004 16:37:33 +0100,
Geoff Caplan <ge***@variosoft.com> wrote:
Dan,
Not just me, thank goodness. The entire Python community. ;-)

DS> I can't help much with your other questions, but I do know about this
DS> one. By definition, blowfish is blowfish is blowfish. Any (properly
DS> implemented) blowfish library will be compatible with another; if you
DS> encode something with one library, you will be able to decode it with
DS> the other.
Thanks for that. Looks like I should persist and track down the
problem. Perhaps something to do with the keys? When I try to
decrypt I am getting binary garbage out instead of an ascii string. Any pointers about where to start looking would be welcome!


I guess the usual pointers apply: Create the absolute smallest program
that fails. Ask the vendors/authors of the library and/or programming
language you're using. Post/Email the code, the input, the actual
output, what you expected to be the output, and why you expected that
output.

I'm pretty sure that counterpane (blowfish' creator, IIRC) has test
vectors, too. If you can encrypt *or* decrypt them, but not both, that
points at one part of your application or another as well.

Regards,
Dan

--
Dan Sommers
<http://www.tombstonezero.net/dan/>
Never play leapfrog with a unicorn.
Jul 18 '05 #4
Geoff Caplan wrote:
Looks like I should persist and track down the
problem. Perhaps something to do with the keys? When I try to
decrypt I am getting binary garbage out instead of an ascii string.

Any pointers about where to start looking would be welcome!


First check the obvious: do you have exactly the same
key/IV/ciphertext.

If that's not it, the most popular bug in Blowfish
implementations is an endian dependency. It causes
implementations to be self-consistent, but ciphertext is not
portable between big-endian and little-endian machines. Bruce
Schneier's original implementation had the bug, and many others
followed.
--
--Bryan
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Daniel Orner | last post by:
Hello, I'm working on a project that consists of a Java application on the desktop, and a server with Python CGI code. I'm trying to find an encryption algorithm, which would let me send...
22
by: Kamilche | last post by:
I've looked at a few alternatives for encryption with Python, and didn't come up anything very speedy. I've written an encryption algorithm in pure Python that can process 22 megs of data a...
4
by: drs | last post by:
Hi, I need to send secure data over an insecure network. To that end, I am needing to encrypt serialized data and then decrypt it. Is there a builtin way to do this in Python? MD5, SHA, etc...
34
by: Blake T. Garretson | last post by:
I want to save some sensitive data (passwords, PIN numbers, etc.) to disk in a secure manner in one of my programs. What is the easiest/best way to accomplish strong file encryption in Python? ...
3
by: Molly Gibson | last post by:
Hi all, I have recently installed Apache/1.3.28 + mod_auth_pgsql-0.9.12 (http://www.giuseppetanzilli.it/mod_auth_pgsql/) The only way I have been able to get it to successfully authenticate...
2
by: thiyagu | last post by:
In our company for internal security compliance we need to encrypt the data to/from DB server; What is the encryption algorithm used by DB2 & what key lengths are supported in DB2 LUW v8 & v9 when...
5
by: Netwatcher | last post by:
well, i started messing around with dictionaries, yet, most of the pages i found about them always talk about getting only one word out of it and turning it vice versa, i've been playing with that...
9
by: Betikci Boris | last post by:
I get bored last night and wrote a script that uses xor for encrypt- decrypt, however it woks fine under linux 2.6.25, text and documents are ok, but fails on compressed files *.jpg, *.pdf , etc ....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.