pub trait SpecificPasswordInit {
// Provided methods
fn normalize(&self) -> Result<SpecificPassword, HapiIronOxideError> { ... }
fn normalize_unseal(
&self,
_idx: Option<&str>,
) -> Result<SpecificPassword, HapiIronOxideError> { ... }
}Expand description
A trait for converting a set of types to SpecificPassword.
use hapi_iron_oxide::password::{SpecificPassword, SpecificPasswordInit};
let password: [u8; 5] = [0x52, 0x6f, 0x5c, 0x42, 0xee];
let normalized_password: SpecificPassword = password.normalize().unwrap();
assert_eq!(normalized_password.id, "".to_string());Provided Methods§
Sourcefn normalize(&self) -> Result<SpecificPassword, HapiIronOxideError>
fn normalize(&self) -> Result<SpecificPassword, HapiIronOxideError>
Normalizes the password to SpecificPassword
use hapi_iron_oxide::password::{SpecificPassword, SpecificPasswordInit};
let password: [u8; 5] = [0x52, 0x6f, 0x5c, 0x42, 0xee];
let normalized_password: SpecificPassword = password.normalize().unwrap();
assert_eq!(normalized_password.id, "".to_string());Sourcefn normalize_unseal(
&self,
_idx: Option<&str>,
) -> Result<SpecificPassword, HapiIronOxideError>
fn normalize_unseal( &self, _idx: Option<&str>, ) -> Result<SpecificPassword, HapiIronOxideError>
Normalizes the password to SpecificPassword, except this one takes in the optional
index of the password in case the user provides the HashMap of password with an ID and
the password.
If the function is given a HashMap, it will try to find the password using the given
index, otherwise it will find the password using the default as key.
use std::collections::HashMap;
use hapi_iron_oxide::password::{Password, SpecificPassword, SpecificPasswordInit};
let password_hashmap: HashMap<String, SpecificPassword> =
HashMap::from([(
"default".to_string(),
SpecificPassword {
id: "".to_string(),
encryption: Password::String("raw_encryption_password_here".to_string()),
integrity: Password::String("raw_integrity_password_here".to_string()),
}
)]);
let specific: SpecificPassword = password_hashmap.normalize_unseal(None).unwrap();
assert_eq!(specific.id, "".to_string());
assert_eq!(specific.encryption, Password::String("raw_encryption_password_here".to_string()));
assert_eq!(specific.integrity, Password::String("raw_integrity_password_here".to_string()));