RSA Rust is a command-line interface (CLI) tool for generating RSA key pairs and encrypting/decrypting messages using the RSA algorithm. This project is ongoing, and future updates will include support for larger numbers.
To use this tool, you need to have Rust installed on your system. You can install Rust by following the instructions at rust-lang.org.
Clone this repository and build the project:
git clone https://github.com/yourusername/rsa_rust.git
cd rsa_rust
cargo build --release
Run the CLI tool with the desired command:
cargo run -- <COMMAND>
Generates an RSA key pair.
Usage:
cargo run -- gen-keys
Encrypts a message using a public key.
Usage:
cargo run -- encrypt-message <MESSAGE> <PUBLIC_KEY_FILE>
Example:
cargo run -- encrypt-message "Hello, World!" public_key.txt
Decrypts a message using a private key and prime numbers.
Usage:
cargo run -- decrypt-message <ENCODED_MESSAGE_FILE> <PRIVATE_KEY_FILE> <PRIME_FILE>
Example:
cargo run -- decrypt-message encoded.txt private_key.txt primes.txt
This project is licensed under the MIT License. See the LICENSE file for details.
The entry point for the CLI tool. It defines the SubCommand
enum for the available commands and their arguments. The main
function parses the command-line arguments and calls the appropriate functions in the rsa_algorithm
module.
The main library file that implements the RSA key generation, encryption, and decryption functions. It defines the following functions:
gen_keys
: Generates RSA key pairs.encrpyt
: Encrypts a message using a public key.decrpyt
: Decrypts a message using a private key and primes.
Contains the implementation of the encrypt
function, which encrypts a message using the RSA algorithm.
Contains the implementation of the decrpyt
function, which decrypts a message using the RSA algorithm and the Chinese Remainder Theorem (CRT).
- Ensure that the public key, private key, and prime files are in the correct format for the encryption and decryption functions to work correctly.
- The
encrpyt
anddecrpyt
functions createencoded.txt
anddecoded.txt
files respectively, which contain the encrypted and decrypted messages.
Feel free to contribute to this project by submitting issues or pull requests on the GitHub repository.