pub struct Argon2Params {
pub m_cost: u32,
pub t_cost: u32,
pub p_cost: u32,
}
Expand description
Argon2 algorithm parameters for customizing security vs performance trade-offs.
用于自定义安全性与性能权衡的 Argon2 算法参数。
§Parameters | 参数
These parameters control the computational cost of Argon2:
这些参数控制 Argon2 的计算成本:
-
Memory Cost (m_cost): Amount of memory used in KB
-
Time Cost (t_cost): Number of iterations
-
Parallelism (p_cost): Number of parallel threads
-
内存成本 (m_cost): 使用的内存量(KB)
-
时间成本 (t_cost): 迭代次数
-
并行度 (p_cost): 并行线程数
§Recommended Values | 推荐值
Use Case | m_cost | t_cost | p_cost | Security Level |
---|---|---|---|---|
Interactive | 65536 | 2 | 1 | Medium |
Server | 262144 | 3 | 4 | High |
Sensitive | 1048576 | 4 | 8 | Very High |
§Security vs Performance | 安全性与性能
Higher values provide better security but require more resources:
- Increase m_cost to resist memory-optimized attacks
- Increase t_cost to resist time-optimized attacks
- Increase p_cost to utilize multiple CPU cores
更高的值提供更好的安全性但需要更多资源:
- 增加 m_cost 以抵抗内存优化攻击
- 增加 t_cost 以抵抗时间优化攻击
- 增加 p_cost 以利用多个 CPU 核心
Fields§
§m_cost: u32
Memory cost in KB (minimum 8).
内存成本(KB)(最小值 8)。
t_cost: u32
Time cost (number of iterations, minimum 1).
时间成本(迭代次数,最小值 1)。
p_cost: u32
Parallelism (number of threads, minimum 1).
并行度(线程数,最小值 1)。
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for Argon2Params
impl<'__de, __Context> BorrowDecode<'__de, __Context> for Argon2Params
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl Clone for Argon2Params
impl Clone for Argon2Params
Source§fn clone(&self) -> Argon2Params
fn clone(&self) -> Argon2Params
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Argon2Params
impl Debug for Argon2Params
Source§impl<__Context> Decode<__Context> for Argon2Params
impl<__Context> Decode<__Context> for Argon2Params
Source§impl<'de> Deserialize<'de> for Argon2Params
impl<'de> Deserialize<'de> for Argon2Params
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Encode for Argon2Params
impl Encode for Argon2Params
Source§impl Hash for Argon2Params
impl Hash for Argon2Params
Source§impl PartialEq for Argon2Params
impl PartialEq for Argon2Params
Source§impl Serialize for Argon2Params
impl Serialize for Argon2Params
impl Copy for Argon2Params
impl Eq for Argon2Params
impl StructuralPartialEq for Argon2Params
Auto Trait Implementations§
impl Freeze for Argon2Params
impl RefUnwindSafe for Argon2Params
impl Send for Argon2Params
impl Sync for Argon2Params
impl Unpin for Argon2Params
impl UnwindSafe for Argon2Params
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