pub struct SecretKey(/* private fields */);Expand description
A crypto_secretbox key. Always exactly 32 bytes - Kalyna256_256Ccm’s key length, this
module’s one fixed construction (see the module doc).
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn generate() -> Result<Self, SecretboxError>
pub fn generate() -> Result<Self, SecretboxError>
Generates a fresh key from the OS CSPRNG - libsodium’s crypto_secretbox_keygen
equivalent, so “how do I make a key” is never a caller decision.
§Errors
Returns SecretboxError::Random if the OS CSPRNG fails.
pub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn as_bytes(&self) -> &[u8; 32]
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnsafeUnpin for SecretKey
impl UnwindSafe for SecretKey
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