pub struct EncryptionKey { /* private fields */ }Expand description
加密密钥(安全存储)
Implementations§
Source§impl EncryptionKey
impl EncryptionKey
Sourcepub fn from_bytes(
key_bytes: &[u8],
algorithm: EncryptionAlgorithm,
) -> Result<Self, EncryptionError>
pub fn from_bytes( key_bytes: &[u8], algorithm: EncryptionAlgorithm, ) -> Result<Self, EncryptionError>
从原始字节创建密钥
Sourcepub fn generate(algorithm: EncryptionAlgorithm) -> Result<Self, EncryptionError>
pub fn generate(algorithm: EncryptionAlgorithm) -> Result<Self, EncryptionError>
生成随机密钥
Sourcepub fn derive_from_password(
password: &str,
salt: &[u8],
algorithm: EncryptionAlgorithm,
) -> Result<Self, EncryptionError>
pub fn derive_from_password( password: &str, salt: &[u8], algorithm: EncryptionAlgorithm, ) -> Result<Self, EncryptionError>
从密码派生密钥
Sourcepub fn key_length(algorithm: EncryptionAlgorithm) -> usize
pub fn key_length(algorithm: EncryptionAlgorithm) -> usize
获取密钥长度
Sourcepub fn nonce_length(algorithm: EncryptionAlgorithm) -> usize
pub fn nonce_length(algorithm: EncryptionAlgorithm) -> usize
获取 Nonce 长度
Sourcepub fn algorithm(&self) -> EncryptionAlgorithm
pub fn algorithm(&self) -> EncryptionAlgorithm
获取算法
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
获取创建时间
Trait Implementations§
Source§impl Clone for EncryptionKey
impl Clone for EncryptionKey
Source§fn clone(&self) -> EncryptionKey
fn clone(&self) -> EncryptionKey
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EncryptionKey
impl RefUnwindSafe for EncryptionKey
impl Send for EncryptionKey
impl Sync for EncryptionKey
impl Unpin for EncryptionKey
impl UnsafeUnpin for EncryptionKey
impl UnwindSafe for EncryptionKey
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