/rust-rsa-unpadded

This repository contains a simple RSA implementation in Rust indended to demonstrate how RSA works.

Primary LanguageRust

Simple RSA Implementation in Rust

This repository contains a simple RSA implementation in Rust indended to demonstrate how RSA works.

Features

  • Key Generation: Generates a public and private key pair using randomly selected prime numbers.
  • Encryption: Encrypts a plaintext message using the public key.
  • Decryption: Decrypts the ciphertext using the private key to retrieve the original plaintext message.

Limitations

  • The program is a demonstration and should not be used for actual secure communications.
  • Currently, it handles plaintext that can be directly converted to numbers and back without loss. Special characters or very long messages may not be supported as expected.

Installation and Running

This guide assumes you have Rust and Cargo installed on your system. If you do not have Rust installed, please visit The Rust Programming Language website to install Rust and Cargo before proceeding.

Cloning the Repository

First, clone the repository to your local machine using Git. Open a terminal and run the following command.

git clone https://github.com/MM-coder/rust-rsa-unpadded

After cloning, navigate into the project's directory:

cd rust-rsa-unpadded

Running with Cargo

Cargo is the Rust package manager and build tool that makes it easy to compile and run Rust projects.

To compile and run the program in one step, use the following command:

cargo run .

Replace arg1 arg2 with the actual arguments your program expects. Building for Release

If you want to compile the program for release, you can use:

cargo build --release

This will compile the program with optimizations. The compiled binary will be located in target/release/ instead of target/debug/. Troubleshooting

Usage

After running the program, you will be prompted to enter a plaintext message that you wish to encrypt. Type your message and press enter. The program will then display the encrypted version of your message as a series of numbers (ciphertext) and the decrypted message, which should match the original plaintext. Example


Enter plaintext to encrypt: Hello, world!
Encrypted: [123456, 234567, ...] // Example output
Decrypted: Hello, world!

This process demonstrates the encryption and decryption capabilities of the program using a simple RSA-like algorithm. The actual numbers in the encrypted output will vary each time you run the program due to the random generation of keys.

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This software is developed as a project with educational or demonstration purposes and is not intended for use in a production environment. The author(s) make no representations regarding the suitability of this software for any purpose and will not be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including but not limited to procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Users are advised to thoroughly test the software in non-production environments and to conduct a comprehensive review of its suitability for any intended use. By using this software, users acknowledge the inherent risks and assume all responsibility for any damages, data loss, or other impacts that may arise from its use.

Furthermore, users should be aware that this software might be updated, changed, or discontinued at any time without notice. It is the user's responsibility to keep the software updated and to review any changes that may affect their usage.

This disclaimer is intended to be as broad and inclusive as permitted by law. If any portion of this disclaimer is held to be invalid or unenforceable, the remaining portions shall remain in full force and effect.