Struct fog_crypto::lock::LockId
source · pub struct LockId { /* private fields */ }
Expand description
An identifier for a corresponding LockKey
that can be used to encrypt data for that key.
This contains a cryptographic public encryption key.
Example
// We've been given a LockId that we're sending encrypted data to.
println!("LockId(Base58): {}", key.id());
// Encrypt some data for that LockId
let data = b"I am sensitive information, about to be encrypted";
let lockbox = id.encrypt_data(data.as_ref());
// The lockbox can be encoded onto a vec or used as raw bytes.
let mut to_send = Vec::new();
to_send.extend_from_slice(lockbox.as_bytes());
Implementations§
source§impl LockId
impl LockId
sourcepub fn encrypt_data(&self, content: &[u8]) -> DataLockbox
pub fn encrypt_data(&self, content: &[u8]) -> DataLockbox
Encrypt a byte slice into a DataLockbox
.
sourcepub fn encrypt_data_with_rng<R>(
&self,
csprng: &mut R,
content: &[u8]
) -> DataLockboxwhere
R: CryptoRng + RngCore,
pub fn encrypt_data_with_rng<R>( &self, csprng: &mut R, content: &[u8] ) -> DataLockboxwhere R: CryptoRng + RngCore,
Encrypt a byte slice into a DataLockbox
. Requires a cryptographic RNG to generate the
needed nonce.
sourcepub fn raw_public_key(&self) -> &[u8] ⓘ
pub fn raw_public_key(&self) -> &[u8] ⓘ
Get the raw public encryption key contained within.
sourcepub fn as_vec(&self) -> Vec<u8> ⓘ
pub fn as_vec(&self) -> Vec<u8> ⓘ
Convert into a byte vector. For extending an existing byte vector, see
encode_vec
.
sourcepub fn from_base58(s: &str) -> Result<Self, CryptoError>
pub fn from_base58(s: &str) -> Result<Self, CryptoError>
Attempt to parse a base58-encoded LockId
.
sourcepub fn encode_vec(&self, buf: &mut Vec<u8>)
pub fn encode_vec(&self, buf: &mut Vec<u8>)
Encode onto an existing byte vector. Writes out the version followed by the public signing key. It does not include any length information in the encoding.
Trait Implementations§
source§impl<'de> Deserialize<'de> for LockId
impl<'de> Deserialize<'de> for LockId
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 PartialEq<LockId> for LockId
impl PartialEq<LockId> for LockId
impl Eq for LockId
impl StructuralEq for LockId
impl StructuralPartialEq for LockId
Auto Trait Implementations§
impl RefUnwindSafe for LockId
impl Send for LockId
impl Sync for LockId
impl Unpin for LockId
impl UnwindSafe for LockId
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