pub struct Crypt {
pub encrypted: String,
/* private fields */
}Expand description
Encryption struct.
Fields§
§encrypted: StringStores encrypted data.
Implementations§
Source§impl Crypt
impl Crypt
Sourcepub fn set_salt(&mut self, salt: String) -> Result<(), NulError>
pub fn set_salt(&mut self, salt: String) -> Result<(), NulError>
Set custom salt for encryption.
use libcrypt_rs::Crypt;
let mut engine = Crypt::new();
engine.set_salt("$1$N1TAWHQs".to_string()).expect("Setting custom salt failed");
println!("{}", engine.get_salt().unwrap());Sourcepub fn gen_salt(&mut self, encryption: Encryptions) -> Result<(), String>
pub fn gen_salt(&mut self, encryption: Encryptions) -> Result<(), String>
Generate salt.
use libcrypt_rs::{Crypt, Encryptions};
let mut engine = Crypt::new();
engine.gen_salt(Encryptions::Sha256).expect("Salt generation failed");
println!("{}", engine.get_salt().unwrap());Sourcepub fn encrypt(&mut self, encrypt: String) -> Result<(), String>
pub fn encrypt(&mut self, encrypt: String) -> Result<(), String>
Encrypt data. Encrypted data can be accessed in the encrypted field of Crypt struct.
use libcrypt_rs::{Crypt, Encryptions};
let mut engine = Crypt::new();
engine.gen_salt(Encryptions::Sha256).expect("Salt generation failed");
engine.encrypt("example_phrase".to_string()).expect("Encryption failed");
println!("Encrypted data: {}", engine.encrypted);Auto Trait Implementations§
impl Freeze for Crypt
impl RefUnwindSafe for Crypt
impl Send for Crypt
impl Sync for Crypt
impl Unpin for Crypt
impl UnsafeUnpin for Crypt
impl UnwindSafe for Crypt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more