Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.19 KB

README.md

File metadata and controls

40 lines (30 loc) · 1.19 KB

rsa_rs

crates.io Documentation dependency status

Rust library containing an implementation of the RSA cryptography algorithim.
Functionality:
-> generate keypairs
-> encrypt / decrypt strings
-> generate random large primes

Example

use rsa_rs::keys::keypair::KeyPair;
use rsa_rs::encryption::encrypt::encrypt_string;
use rsa_rs::encryption::decrypt::decrypt_string;
use num_bigint::BigUint;

let key_pair: String = KeyPair::generate_key_pair(65537, 1024);
let public_key: &PublicKey = key_pair.public_key();
let private_key: &PrivateKey = key_pair.private_key();

let s = String::from("hello");
let encrypted_string: Vec<BigUint> = encrypt_string(&s, public_key);
let decrypted_string: String = decrypt_string(&encrypted_string, private_key);

assert_eq!(s, decrypted_string);