Struct safe_crypto::PublicEncryptKey [−][src]
pub struct PublicEncryptKey { /* fields omitted */ }The public key used encrypt data that can only be decrypted by the corresponding secret key,
which is represented by SecretEncryptKey.
Use gen_encrypt_keypair() to generate a public and secret key pair.
Methods
impl PublicEncryptKey[src]
impl PublicEncryptKeypub fn from_bytes(public_key: [u8; 32]) -> Self[src]
pub fn from_bytes(public_key: [u8; 32]) -> SelfConstruct public key from bytes. Useful when it was serialised before.
pub fn into_bytes(self) -> [u8; 32][src]
pub fn into_bytes(self) -> [u8; 32]Convert the PublicEncryptKey into the raw underlying bytes.
For anyone who wants to store the public key.
pub fn anonymously_encrypt<T>(&self, plaintext: &T) -> Result<Vec<u8>, Error> where
T: Serialize, [src]
pub fn anonymously_encrypt<T>(&self, plaintext: &T) -> Result<Vec<u8>, Error> where
T: Serialize, Encrypts serialisable plaintext using anonymous encryption.
Anonymous encryption will use an ephemeral public key, so the recipient won't
be able to tell who sent the ciphertext.
If you wish to encrypt bytestring plaintext, use anonymously_encrypt_bytes.
To use authenticated encryption, use SharedSecretKey.
Returns ciphertext in case of success.
Can return an Error in case of a serialisation error.
pub fn anonymously_encrypt_bytes(&self, plaintext: &[u8]) -> Vec<u8>[src]
pub fn anonymously_encrypt_bytes(&self, plaintext: &[u8]) -> Vec<u8>Encrypts bytestring plaintext using anonymous encryption.
Anonymous encryption will use an ephemeral public key, so the recipient won't
be able to tell who sent the ciphertext.
To use authenticated encryption, use SharedSecretKey.
Returns ciphertext in case of success.
Trait Implementations
impl Debug for PublicEncryptKey[src]
impl Debug for PublicEncryptKeyfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Hash for PublicEncryptKey[src]
impl Hash for PublicEncryptKeyfn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl PartialEq for PublicEncryptKey[src]
impl PartialEq for PublicEncryptKeyfn eq(&self, other: &PublicEncryptKey) -> bool[src]
fn eq(&self, other: &PublicEncryptKey) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &PublicEncryptKey) -> bool[src]
fn ne(&self, other: &PublicEncryptKey) -> boolThis method tests for !=.
impl Eq for PublicEncryptKey[src]
impl Eq for PublicEncryptKeyimpl PartialOrd for PublicEncryptKey[src]
impl PartialOrd for PublicEncryptKeyfn partial_cmp(&self, other: &PublicEncryptKey) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &PublicEncryptKey) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &PublicEncryptKey) -> bool[src]
fn lt(&self, other: &PublicEncryptKey) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &PublicEncryptKey) -> bool[src]
fn le(&self, other: &PublicEncryptKey) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &PublicEncryptKey) -> bool[src]
fn gt(&self, other: &PublicEncryptKey) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &PublicEncryptKey) -> bool[src]
fn ge(&self, other: &PublicEncryptKey) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Ord for PublicEncryptKey[src]
impl Ord for PublicEncryptKeyfn cmp(&self, other: &PublicEncryptKey) -> Ordering[src]
fn cmp(&self, other: &PublicEncryptKey) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl Clone for PublicEncryptKey[src]
impl Clone for PublicEncryptKeyfn clone(&self) -> PublicEncryptKey[src]
fn clone(&self) -> PublicEncryptKeyReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for PublicEncryptKey[src]
impl Copy for PublicEncryptKeyimpl Display for PublicEncryptKey[src]
impl Display for PublicEncryptKeyAuto Trait Implementations
impl Send for PublicEncryptKey
impl Send for PublicEncryptKeyimpl Sync for PublicEncryptKey
impl Sync for PublicEncryptKey