Expand description
A crate that uses the already well established rsa and pkcs8 crates to provide a simple plug and play experience.
§Usage
§Saving key pairs
use srsa::Keys;
use anyhow::Result as AnyResult;
fn main() -> AnyResult<()> {
// The values passed in will be the file names of the private and public keys.
let keys = Keys::new("priv", "pub");
// Saves the key pairs to a folder in the cwd called keys and encrypts the private key with a
// password
keys.write_to_disk("password", "keys")?;
Ok(())
}
§Using an existing key pair
use srsa::Keys;
use anyhow::Result as AnyResult;
fn main() -> AnyResult<()> {
let keys = Keys::retrieve_keys("keys/test_priv", "1234", "keys/test_pub")?;
let ciphertext = keys.seal(b"hi")?;
let plaintext = keys.unseal(&ciphertext)?;
Ok(())
}
Encrypting and decrypt things work very similarly.
- You retrieve the neccessary keys to do the job.
- You run the appropriate function. The encryption function called
seal
, the decryption function is calledunseal
.
Modules§
- errors
- A few error conversions into a custom error type.
Structs§
- Keys
- Contains the key pairs and their names. This struct is to use the key pairs and to retrieve them. It can also be used to create new key pairs.