[−][src]Crate rsa
RSA Implementation in pure Rust.
Usage
extern crate rsa; extern crate rand; use rsa::{PublicKey, RSAPrivateKey, PaddingScheme}; use rand::rngs::OsRng; let mut rng = OsRng; let bits = 2048; let key = RSAPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); // Encrypt let data = b"hello world"; let enc_data = key.encrypt(&mut rng, PaddingScheme::PKCS1v15, &data[..]).expect("failed to encrypt"); assert_ne!(&data[..], &enc_data[..]); // Decrypt let dec_data = key.decrypt(PaddingScheme::PKCS1v15, &enc_data).expect("failed to decrypt"); assert_eq!(&data[..], &dec_data[..]);
Re-exports
pub use self::padding::PaddingScheme; |
Modules
| algorithms | Useful algorithms. |
| errors | Error types. |
| hash | Supported hash functions. |
| padding | Supported padding schemes. |
Structs
| BigUint | A big unsigned integer type. |
| RSAPrivateKey | Represents a whole RSA key, public and private parts. |
| RSAPublicKey | Represents the public part of an RSA key. |
Traits
| PublicKey | Generic trait for operations on a public key. |