pub struct Argon2 {
pub m_cost: u32,
pub t_cost: u32,
pub p_cost: u32,
pub hash_length: u64,
pub algorithm: Algorithm,
pub version: Version,
}Expand description
Argon2 instance
§Parameters
m_cost- The memory cost in kibibytest_cost- Iteration costp_cost- Parallelizationhash_length- The length of the hash in bytesalgorithm- The algorithm to useversion- The version of the algorithm to use
By default it will use the Argon2id with a 64 byte hash length (maximum).
It is not recomended to change them, the default values are fine for most use cases.
Generally speaking you don’t want to mess with the t_cost and p_cost parameters a lot.
For max security the p_cost should be set to 1 and the t_cost could be anything between 8 and 30.
That also depends on the m_cost which is the most important parameter.
The higher the m_cost the more secure the hash is but the time it takes to compute it increases linearly.
§Presets
There are some presets for the Argon2 struct that you can use.
Argon2::very_fast()Argon2::fast()Argon2::balanced()Argon2::slow()Argon2::very_slow()
Fields§
§m_cost: u32§t_cost: u32§p_cost: u32§hash_length: u64§algorithm: AlgorithmBy default we use the Argon2id
version: VersionBy default we use the version 0x13
Implementations§
Source§impl Argon2
impl Argon2
Sourcepub fn new(m_cost: u32, t_cost: u32, p_cost: u32) -> Self
pub fn new(m_cost: u32, t_cost: u32, p_cost: u32) -> Self
Create a new Argon2 instance with the given parameters.
By default it will use the Argon2id with a 64 byte hash length.
§Arguments
m_cost- The memory cost in kibibytest_cost- Iteration costp_cost- Parallelization