pub struct Params { /* private fields */ }Expand description
The Argon2 parameters used for the encrypted data.
Implementations§
Source§impl Params
impl Params
Sourcepub fn new(ciphertext: impl AsRef<[u8]>) -> Result<Self>
pub fn new(ciphertext: impl AsRef<[u8]>) -> Result<Self>
Creates a new instance of the Argon2 parameters from ciphertext.
§Errors
Returns Err if any of the following are true:
ciphertextis shorter than 164 bytes.- The magic number is invalid.
- The version number is the unsupported abcrypt version number.
- The version number is the unrecognized abcrypt version number.
- The Argon2 type is invalid.
- The Argon2 version is invalid.
- The Argon2 parameters are invalid.
§Examples
let ciphertext = include_bytes!("../tests/data/v1/argon2id/v0x13/data.txt.abcrypt");
assert!(Params::new(ciphertext).is_ok());Sourcepub const fn memory_cost(&self) -> u32
pub const fn memory_cost(&self) -> u32
Gets memory size in KiB.
§Examples
let ciphertext = include_bytes!("../tests/data/v1/argon2id/v0x13/data.txt.abcrypt");
let params = Params::new(ciphertext).unwrap();
assert_eq!(params.memory_cost(), 32);Sourcepub const fn time_cost(&self) -> u32
pub const fn time_cost(&self) -> u32
Gets number of iterations.
§Examples
let ciphertext = include_bytes!("../tests/data/v1/argon2id/v0x13/data.txt.abcrypt");
let params = Params::new(ciphertext).unwrap();
assert_eq!(params.time_cost(), 3);Sourcepub const fn parallelism(&self) -> u32
pub const fn parallelism(&self) -> u32
Gets degree of parallelism.
§Examples
let ciphertext = include_bytes!("../tests/data/v1/argon2id/v0x13/data.txt.abcrypt");
let params = Params::new(ciphertext).unwrap();
assert_eq!(params.parallelism(), 4);Trait Implementations§
impl Copy for Params
Auto Trait Implementations§
impl Freeze for Params
impl RefUnwindSafe for Params
impl Send for Params
impl Sync for Params
impl Unpin for Params
impl UnwindSafe for Params
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