Authors | Project | Build Status | Latest Version | License |
---|---|---|---|---|
N. Curti A. Fabbri |
CryptoSocket | Linux/MacOS : Windows : |
CryptoSocket supports a pure Python implementation with some C++ features. To install the two components see the section below.
The Python version depends only by Numpy library and the Socket package.
The C++ version supports c++ standard 11 and it does not need extra dependencies.
First of all clone the project:
git clone https://github.com/Nico-Curti/CryptoSocket
cd CryptoSocket
For the Python installation just type:
python setup.py install
or
python setup.py develop --user
for an installation in development mode.
For the C++ installation use the build.sh
script if you are in Unix OS or the build.ps1
for the Windows users.
For any troubles with the dependencies installation we recommend the use of ShUt which includes a complete set of no root-user installation scripts.
In the example folder you can find a pair of client-server scripts to test the connection. First of all open two local shell. Pay attention to start the server before the client! In the first one run the command
python server.py -l localhost -r localhost -a 8080 -t 8087
You can see that this shell starts to wait messages from a putative client. Thus, in the second one we will send something using the client script with the command
python client.py -l localhost -r localhost -a 8087 -t 8080
You will see that the server shell has received the message send by the client and print the same message on its shell. You should see something like
starting up on localhost port 8080
waiting for a connection...
receiving...
Object ObjectToTransfer:
Number of members: 3
arr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
msg: This is the message.
num: 3.14
waiting for a connection...
Different kind of data are send by the client at the same time. You can manage the client script to your needs and try to send also more complex python object. Each message will be serialized using pickle
so any Python class is allowed.
You can perform more sophisticated messages using the RSA cryptography inside the Crypto submodule just passing the keyfile in the previous command line. In this case the message will be encrypted by the client and decrypted by the server.
First of generate the couples of key-file needed by the RSA algorithm. The generate_key.py file allows you to create a public and private key (in plain text) with the two keys. The you can use the encrypt.py script to encrypt a plain text as
python encrypt.py -k ./my_secret_private_key_filename.dat -f "this repo is amazing"
>>> [139, 345, 150, 312, 296, 361, 745, 701, 342, 296, 150, 312, 296, 487, 406, 487, 243, 150, 616, 372]
The with the decrypt.py script we re-convert the encoded text to plain with the public key
python decrypt.py -k ./my_public_key_filename.dat -c 139 345 150 312 296 361 745 701 342 296 150 312 296 487 406 487 243 150 616 372
>>> this repo is amazing
The same script are callable also with the pure-C++ implementation of the RSA algorithm in the second example directory.
Any contribution is more than welcome ❤️. Just fill an issue or a pull request and I will check ASAP!
See also the list of contributors who participated in this project.
If you have found CryptoSocket
helpful in your research, please consider citing the
@misc{CryptoSocket,
author = {Nico Curti, Alessandro Fabbri},
title = {CryptoSocket - TCP/IP Client Server with RSA cryptography},
year = {2019},
publisher = {GitHub},
howpublished = {\url{https://github.com/Nico-Curti/CryptoSocket}},
}