Skip to content

Python script implementing the RSA encryption and decryption protocol

Notifications You must be signed in to change notification settings

reaganman/python-rsa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

python-rsa

This Python script implements the RSA encryption and decryption protocol. It allows you to generate RSA key pairs and encrypt/decrypt files using the generated keys.

Author: Reagan McKee

Contents

Introduction

This python RSA script allows you to generate RSA key pairs, encrypt plaintext files, and decrypt encrypted files using the generated keys. It employs the RSA encryption algorithm with Miller-Rabin primality testing.

Prerequisites

Make sure you have Python installed on your machine. You can download it from python.org.

Installation

Clone the repository to your local machine:

git clone https://github.com/reaganman/python-rsa.git
cd python-rsa

Usage

Generate RSA Keys

To generate RSA keys, run rsa.py with the --keygen option:

python3 rsa_script.py keyphrase.txt --keygen

Replace keyphrase.txt with the path to a text file containing two lines of input strings to use a keypharse for key generation

Encrypt a File

To encrypt a plaintext file using the generated public key, run the following command:

python3 rsa_script.py keyfile.txt --encrypt input.txt

Replace keyfile.txt with the same key file used for key generation, and input.txt with the path to the file you want to encrypt.

This command will read the public key generated from keyphrase.txt, encrypt the contents of input.txt, and save the encrypted result to an output file. The output file will be named based on the input file, appended with "_encrypted.txt".

Decrypt a File

To decrypt a plaintext file using the generated private key, run the following command:

python3 rsa_script.py keyfile.txt --decrypt encrypted_file.txt

Replace keyfile.txt with the same key file used for key generation, and encrypted_file.txt with the path to the file you want to decrypt.

The output file will be named based on the input file, appended with "_decrypted.txt".

About

Python script implementing the RSA encryption and decryption protocol

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages