I was wondering if there is any straightforward way to encrypt text or string in C so it can easily be decrypted in python using shared key encryption (AES) ?
-
1Which encryption algorithm are you going to use? If you pick one that has both a C and a Python implementation, that's the straightforward way. Which algorithm do you think you want to use?S.Lott– S.Lott2011-02-28 22:16:35 +00:00Commented Feb 28, 2011 at 22:16
-
I think I will use symmetric encryption with AESm1k3y3– m1k3y32011-02-28 22:35:41 +00:00Commented Feb 28, 2011 at 22:35
-
2Please update your question to state that you plan to use AES. Then, please search using Google for AES implementations in Python and C. Then, please ask any specific questions on the implementations you found.S.Lott– S.Lott2011-02-28 22:44:17 +00:00Commented Feb 28, 2011 at 22:44
2 Answers
I would recommend calling GPG, the Gnu Privacy Gaurd in C via GPGME. You can read the data with Python using python-gnupg. This is the most secure option since you are relying on an open source, peer reviewed, and widely used cryptography implementation (GPG). There are many, many security pitfalls when implementing cryptography. In general, application developers should not implement cryptography themselves.
Comments
PyCrypto (not distributed as part of Python) implements algorithms like AES, and Mozilla Network Security Services provides C libraries to use encryption algorithms in C. Alternatively, there is OpenSSL, but its documentation is lacking.
I'd recommend a commonly used one like AES or Blowfish.