Skip to content

KirollosSamy/RSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSA implementation in Python

Python Version License

Table of Contents

Installation

To install the dependencies, run the following commands:

pip install pycryptodome
pip install socket
pip install tqdm
pip install matplotlib

Usage

To use the program, split the terminal and run the server and client chatters in separate terminals

To run the Server use the command:

python server.py

To run the Client use the command:

python client.py

Please make sure to run the server first and then the client

To close the chat simply type

exit

That's it! you can start chatting now and all your conversations are secured with RSA 🔒

Code Walkthrough

transmorpher.py

The Transmorpher class is responsible for encoding and decoding messages.

rsa.py

This is the core class where RSA encryption and decryption is implemented. The class constructor takes the key size in bits and a class for encoding/decoding (Transmorpher). Dependency injection is used so that the RSA class doesn't depend on how the encoding/decoding is done, and different schemes can be used without any changes to the RSA class. The class includes the following public methods:

  • generate_keys()
  • encrypt()
  • decrypt()

chatter.py

The Chatter class is a virtual class responsible for handling the sockets and threading. It has two main methods:

  • connect()
  • chat()

The two classes ClientChatter and ServerChatter inherit from this class and implement the virtual function connect().

client.py & server.py

The ClientChatter and ServerChatter classes are defined here. In the main function, an object of each chatter is created and used for chatting.

break_rsa.ipynb

The code for breaking RSA is implemented in this notebook, In addition, the analysis results and conclusions are shown at the end.

About

RSA implementation in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published