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 PublicEncryptKey
pub fn from_bytes(public_key: [u8; 32]) -> Self
[src]
pub fn from_bytes(public_key: [u8; 32]) -> Self
Construct 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 PublicEncryptKey
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Hash for PublicEncryptKey
[src]
impl Hash for PublicEncryptKey
fn 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 PublicEncryptKey
fn eq(&self, other: &PublicEncryptKey) -> bool
[src]
fn eq(&self, other: &PublicEncryptKey) -> bool
This 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) -> bool
This method tests for !=
.
impl Eq for PublicEncryptKey
[src]
impl Eq for PublicEncryptKey
impl PartialOrd for PublicEncryptKey
[src]
impl PartialOrd for PublicEncryptKey
fn 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) -> bool
This 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) -> bool
This 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) -> bool
This 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) -> bool
This 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 PublicEncryptKey
fn cmp(&self, other: &PublicEncryptKey) -> Ordering
[src]
fn cmp(&self, other: &PublicEncryptKey) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Clone for PublicEncryptKey
[src]
impl Clone for PublicEncryptKey
fn clone(&self) -> PublicEncryptKey
[src]
fn clone(&self) -> PublicEncryptKey
Returns 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 PublicEncryptKey
impl Display for PublicEncryptKey
[src]
impl Display for PublicEncryptKey
Auto Trait Implementations
impl Send for PublicEncryptKey
impl Send for PublicEncryptKey
impl Sync for PublicEncryptKey
impl Sync for PublicEncryptKey