The purpose of this project is to show an example of python encrypting a string, using RSA encryption, then decrypting that using C#.
As such, it includes 2 areas: - A python module area (./python) - A C# solution area (./csharp) - To be opened in Visual Studio
The project should work out of the box, with a little setup:
cd python
virutalenv env
. ./env/bin/activate
pip install -r requirements.txt
Just open ./csharp/EncryptionDemos/EncryptionDemos.sln
in Visual Studio 2010 or later
cd python
. ./env/bin/activate
python encrypt.py
That will generate a file outside the python and c# areas called encrypted.txt.
- From visual studio, run the project
- Choose option 2
That should show you the original string from the encrypt.py script ("hello there!" is the default)
The project comes with sample keys but if you want to create new ones, you can do so.
The keys are initially created in C#:
- From visual studio, run the project
- Choose option 1
That will create a PrivateKey.txt and PublicKey.txt at the root of this repository (outside both the Python and C# areas).
The PrivateKey.txt can be copied directly into the ./csharp/EncryptionDemos
directory.
For python, the PublicKey.txt
string needs to be converted into PEM format. You can use this utility from SuperDry Developer to do that conversion. Once you have it, paste it into ./python/publickey.pem
.