Skip to content

lccasagrande/Textbook-RSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This repository contains a Python implementation of Textbook RSA using Miller-Rabin primality test.

If you don't know how RSA works, take a look at this book: CORMEN, Thomas H. et al. Introduction to algorithms. MIT press, 2009.

Requirements

You'll need Python 3.x x64 to be able to run theses projects.

If you do not have Python installed yet, it is recommended that you install the Anaconda distribution of Python, which has almost all packages required in these project.

You can also install Python 3.x x64 from here

Instructions

  1. Clone the repository and navigate to the downloaded folder.

    git clone https://github.com/lccasagrande/Textbook-RSA.git
    cd Textbook-RSA
  2. Install required packages:

    pip install -e .

    Or:

    pip install -e . --user
  3. Navigate to the src folder:

    cd src
  4. Generate Keys:

    python keygen.py -v 1 --output_dir "../test/" --key_size 2048
  5. Encrypt file

    python encrypt.py -v 1 --key "../test/public_key.der" --file "../test/text.txt"
  6. Decrypt File

    python decrypt.py -v 1 --key "../test/private_key.der" --file "../test/text.txt"
  7. Optional: It's possible to use the Pollard's Rho algorithm to break the RSA key. Do not use it with large key sizes, 32 bits should be a good first try.

    • Generate key with 32 bits:
    python keygen.py -v 1 --output_dir "../test/" --key_size 32
    • Encrypt file
    python encrypt.py -v 1 --key "../test/public_key.der" --file "../test/text.txt"
    • Run Pollard's Rho
    python pollard_rho.py -v 1 --public_key "../test/public_key.der" --output_dir "../test/"
    • Decrypt file
    python decrypt.py -v 1 --key "../test/pollard_private_key.der" --file "../test/text.txt"

About

A Textbook RSA implementation in Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages