Code Monkey home page Code Monkey logo

cryptosocket's Introduction

Authors Project Build Status Latest Version License
N. Curti
A. Fabbri
CryptoSocket Linux/MacOS : Travis
Windows : appveyor
version license

GitHub pull-requests GitHub issues

GitHub stars GitHub watchers

CryptoSocket

TCP/IP Client Server with RSA cryptography

  1. Prerequisites
  2. Installation
  3. Usage
  4. Contribution
  5. Authors
  6. Citation

Prerequisites

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.

Installation

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.

Usage

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.

Contribution

Any contribution is more than welcome ❤️. Just fill an issue or a pull request and I will check ASAP!

Authors

See also the list of contributors who participated in this project.

Citation

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}},
}

cryptosocket's People

Contributors

nico-curti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.