Struct fog_crypto::lock::LockId[][src]

pub struct LockId { /* fields omitted */ }

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(&mut csprng, 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

impl LockId[src]

pub fn encrypt_data<R>(&self, csprng: &mut R, content: &[u8]) -> DataLockbox where
    R: CryptoRng + RngCore
[src]

Encrypt a byte slice into a DataLockbox. Requires a cryptographic RNG to generate the needed nonce.

pub fn version(&self) -> u8[src]

Get the cryptographic algorithm version used for this ID.

pub fn raw_public_key(&self) -> &[u8][src]

Get the raw public encryption key contained within.

pub fn as_vec(&self) -> Vec<u8>[src]

Convert into a byte vector. For extending an existing byte vector, see encode_vec.

pub fn from_base58(s: &str) -> Result<Self, CryptoError>[src]

Attempt to parse a base58-encoded LockId.

pub fn to_base58(&self) -> String[src]

Convert into a base58-encoded LockId.

pub fn encode_vec(&self, buf: &mut Vec<u8>)[src]

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.

pub fn size(&self) -> usize[src]

Get the length of this Identity once encoded as bytes.

Trait Implementations

impl Clone for LockId[src]

impl Debug for LockId[src]

impl<'de> Deserialize<'de> for LockId[src]

impl Display for LockId[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Display as a base58-encoded string.

impl Eq for LockId[src]

impl Hash for LockId[src]

impl LowerHex for LockId[src]

impl PartialEq<LockId> for LockId[src]

impl Serialize for LockId[src]

impl StructuralEq for LockId[src]

impl StructuralPartialEq for LockId[src]

impl TryFrom<&'_ [u8]> for LockId[src]

type Error = CryptoError

The type returned in the event of a conversion error.

impl UpperHex for LockId[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,