Example of sharing encrypted information between Python and the .NET Framework
Python C#
Latest commit 4940144 Oct 9, 2014 @janglin Merge pull request #1 from owenfi/master
Add setup.py so this can be installed with pip automatically
Permalink
Failed to load latest commit information.
LICENSE Initial commit Feb 10, 2013
README.md Cleanup formatting Oct 9, 2014
pkcs1.py Initial commit Feb 10, 2013
pkcs7.py Initial commit Feb 10, 2013
pyaes.py Initial commit Feb 10, 2013
pyrsa.py Initial commit Feb 10, 2013
setup.py Add a setup file so the package can be installed with pip Oct 9, 2014
slaes.cs Initial commit Feb 10, 2013

README.md

crypto-pkcs7-example

An example taken from the site below for posteriety (requires pycrypto) and getting up to speed

from Crypto.Cipher import AES
from pkcs7 import PKCS7Encoder
import base64

key = 'your key 16bytes'
# 16 byte initialization vector
iv = '1234567812345678'

aes = AES.new(key, AES.MODE_CBC, iv)
encoder = PKCS7Encoder()

text = 'This is my plain text'

# pad the plain text according to PKCS7
pad_text = encoder.encode(text)
# encrypt the padding text
cipher = aes.encrypt(pad_text)
# base64 encode the cipher text for transport
enc_cipher = base64.b64encode(cipher)

print enc_cipher

There isn't an offical release per se, but to use it with pip add the following to your requirements.txt file:

-e git+https://github.com/owenfi/crypto-pkcs7-example.git#egg=pkcs

or

-e git+https://github.com/owenfi/crypto-pkcs7-example.git@15180eeacab6fbc5772cf7fd6687dd712e5d763b#egg=pkcs-master

to get a specific release

Example of sharing encrypted information between Python and the .NET Framework. It contains a Python implementation of RFC 2315 PKCS#7 encoding. It also contains a Python implementation of RFC 2437 PKCS1-v1_5 encoding and PKCS1-v2.0 (OAEP) encoding. In this example, the data is encrypted in Python and decrypted using the .NET Framework and the C# language.

This code was originally used as part of this blog post. http://japrogbits.blogspot.com/2011/02/using-encrypted-data-between-python-and.html

The PyCrypto library is available at: https://github.com/dlitz/pycrypto with documentation here: https://www.dlitz.net/software/pycrypto/