Crate libcrypt_rs
source · [−]Expand description
rust binding for POSIX crypt library (libcrypt)
Example
// Import Crypt struct and Encryptions enum.
use libcrypt_rs::{Crypt, Encryptions};
fn main() {
// Create new instance of Crypt object.
let mut engine = Crypt::new();
// Generate new encryption salt for sha256crypt encryption algorithm.
engine.gen_salt(Encryptions::Sha256).expect("Salt generation failed");
// Encrypt "1234" string.
engine.encrypt("1234".to_string()).expect("Encryption failed");
// Encrypted data is stored in engine.encrypted. Let's print it to stdout.
println!("Encrypted data: '{}'", engine.encrypted);
}
Re-exports
pub use encryptions::Encryptions;
Modules
Encryption methods.
Raw bindings to libcrypt. unsafe rust required
Structs
Encryption struct.