Mild RSA implementation written in Rust for a class.

Overview

rust_rsa

About this repo

This is my Rust implementation of the RSA encryption standard, based on this book.
This is for my CS 3000 - Advanced Algorithms & Data Structures class at SUU, taught by Professor Nathan Barker in the Spring 2022 semester.

How to use

Prerequisities

A Rust compiler that supports version 2021.
Having e.txt in the same working directory as the binary, once built. Should be a small-ish prime number, 65537 is a great starter.
Having message.txt in the same working directory as the binary, once built. Should be a message you wish to encode!

Building and Testing

Just run cargo test to ensure everything works as intended, and then run cargo build --release to get a binary.
Once you have this binary, a command line interface is exposed.

CLI

Running anything other than one of three preset commands will give you the help screen. Here it is now:

Help for RSA
List of possible args: [gen, encrypt, decrypt]
gen -> Generates and writes `d.txt` and `n.txt` to the current directory. Takes A WHILE even on good computers.
encrypt -> Takes `message.txt`, `e.txt`, and `n.txt` and encrypts the message, outputting `encryptedMessage.txt`.
decrypt -> Takes `encryptedMessage.txt`, `d.txt`, and `n.txt` and decrypts the message, printing it out in the console.

Using it to encrypt then decrypt a message

You basically just go in the order of CLI args.
First, you gen your public and private keys. Note that this took about 2 minutes on my decently-powered computer, as it has to keep randomly trying until it gets a prime.
Next, you have it encrypt your message.txt using encrypt and it spits out encryptedMessage.txt.
Finally, you run decrypt to decrypt encryptedMessage.txt and output it to your console!

You might also like...
Rust implementation of ESP32 NVS partition generator.

Simple ESP32 NVS writer library for Rust Overview A library for Rust to generate NVS partitions for ESP32. How to use See examples/write_simple.rs. Ma

LSR - A Rust Implementation of LS for Windows
LSR - A Rust Implementation of LS for Windows

LSR - A Rust Implementation of LS for Windows(and possibly other platforms) This is underdevelopment Quick Start For now, I only tested this code on t

The most primitive and the fastest implementation of a fixed-size last-in-first-out stack on stack in Rust, for Copy-implementing types

This is the simplest and the fastest (faster than Vec!) implementation of a last-in-first-out stack data structure, on stack, when stack elements are

A mimimal Rust implementation of Llama.c
A mimimal Rust implementation of Llama.c

llama2.rs Rust meets llama. A mimimal Rust implementation of karpathy's llama.c. Currently the code uses the 15M parameter model provided by Karpathy

A rust and SageMath implementation of (2,2)-isogenies in the theta model

An Algorithmic Approach to (2, 2)-isogenies in the Theta Model Code accompanying the research paper: An Algorithmic Approach to (2, 2)-isogenies in th

unFlow is a Design as Code implementation, a DSL for UX & backend modeling. DSL to Sketch file, Sketch to DSL, DSL to code.

unflow 是一个低代码、无代码设计语言。unFlow is a Design as Code implementation, a DSL for UX & backend modeling. DSL to Sketch file, Sketch to DSL, DSL to code.

A minimal RedDSA implementation for use in Zebra and zcashd.

A minimal RedDSA implementation for use in Zcash. Two specializations of RedDSA are used in Zcash: RedJubjub and RedPallas. For each of these, two par

A language server implementation for the WGSL shading language

wgsl-analyzer wgsl-analyzer is a language server plugin for the WGSL Shading language. It comes with a VS Code plugin located in ./editors/code, but d

Default implementation of the Wayland protocol for use with wl

Wayland An implementation of core Wayland interfaces and convenience functions for accelerating the development of Wayland clients and servers using t

Owner
Star
Star
The official rust implementation of the SpamProtectionBot API

SpamProtection-rs Table of contents About Supported Rust version Features How to use Credits License About SpamProtection-Rust is a Rust wrapper for I

Intellivoid 0 Feb 26, 2022
RusTiny -- A Rust implementation of Tiny+ language

RusTiny -- A Rust implementation of Tiny+ language 编译器实践 基本要求: 参考《编译原理及实践》的TINY语言编译器(已上传到群中)完成TINY+ 语言(见附录 A)的解释器:即给定满足 TINY+语言的源代码输入,你的解 释器可以给出对其的解释执

M4tsuri 2 May 22, 2022
kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

Vinícius Miguel 26 Dec 5, 2022
An implementation of Joker Calculus in Rust

Joker Calculus An implementation of Joker Calculus in Rust Based on paper Joker Calculus, by Daniel Fischer, William Alexander Morris and Sven Nilsen

AdvancedResearch 4 Jan 17, 2022
dustls, a pure-rust DTLS implementation

dustls, a pure-rust DTLS implementation A DTLSv1.2 implementation in Rust, reusing rustls for cryptographic primitives and most message payload format

Jonathan de Jong 10 Nov 28, 2022
A clean implementation of Reso using Rust.

A clean implementation of Reso using Rust. The principle of Reso Rust is almost identical to Reso, only missing some functionality

Matas Minelga 12 Nov 26, 2022
An experimental implementation of gitbom in Rust

gitbom-rs "An experimental implementation of GitBOM in Rust" NOTICE: This project is still a work in progress and is not ready for any use beyond expe

GitBOM 9 Sep 1, 2022
Rust implementation for parsing StarCraft .chk files.

bwmap Rust implementation for parsing StarCraft .chk files. bounding.net uses this library to parse StarCraft and StarCraft: Brood War maps and store

null 8 Dec 19, 2022
rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust.

rlox-interpreter rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust. Disclaimer: This is my first Rust project, d

Paul Fedorow 3 Oct 5, 2022
Rust implementation for Wlroots (Sway, Wayfire, Hikari, River, etc.) of Gnome Screenshot and Idle DBUS Server, which Upwork uses to capture the screen as proof of work.

?? upwork-wlroots-bridge ?? Rust Implementation for Wlroots (Sway, Wayfire, Hikari, River, etc.) of Gnome Screenshot and Idle DBUS Server (with extra

Daniel Moretti V. 4 Jan 2, 2023