Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encrypt a string in Python and decrypt that same string in PHP?

Tags:

python

php

I have a string that I would like to encrypt in Python, store it as a cookie, then in a PHP file I'd like to retrieve that cookie, and decrypt it in PHP. How would I go about doing this?


I appreciate the fast responses.

All cookie talk aside, lets just say I want to encrypt a string in Python and then decrypt a string in PHP.

Are there any examples you can point me to?

like image 668
Adam Ross Avatar asked Dec 14 '22 00:12

Adam Ross


2 Answers

Use a standard encryption scheme. The implementation is going to be equivalent in either language.

RSA is available (via third party libraries) in both languages, if you need asymmetric key crypto. So is AES, if you need symmetric keys.

like image 149
Kevin Montrose Avatar answered Feb 01 '23 23:02

Kevin Montrose


There is a good example here:
http://www.codekoala.com/blog/2009/aes-encryption-python-using-pycrypto/

Other links that may help:
http://www.phpclasses.org/browse/package/4238.html
http://www.chilkatsoft.com/p/php_aes.asp

like image 25
psytek Avatar answered Feb 02 '23 00:02

psytek