Struct libsignal_service::profile_cipher::ProfileCipher
source · pub struct ProfileCipher { /* private fields */ }
Expand description
Encrypt and decrypt a ProfileName
and other profile information.
§Example
let profile_key = ProfileKey::generate(some_randomness);
let name = ProfileName::<&str> {
given_name: "Bill",
family_name: None,
};
let cipher = ProfileCipher::from(profile_key);
let encrypted = cipher.encrypt_name(&name).unwrap();
let decrypted = cipher.decrypt_name(&encrypted).unwrap().unwrap();
assert_eq!(decrypted.as_ref(), name);
Implementations§
source§impl ProfileCipher
impl ProfileCipher
pub fn into_inner(self) -> ProfileKey
pub fn decrypt_avatar( &self, bytes: &[u8], ) -> Result<Vec<u8>, ProfileCipherError>
pub fn encrypt_name<'inp>( &self, name: impl Borrow<ProfileName<&'inp str>>, ) -> Result<Vec<u8>, ProfileCipherError>
pub fn decrypt_name( &self, bytes: impl AsRef<[u8]>, ) -> Result<Option<ProfileName<String>>, ProfileCipherError>
pub fn encrypt_about( &self, about: String, ) -> Result<Vec<u8>, ProfileCipherError>
pub fn decrypt_about( &self, bytes: impl AsRef<[u8]>, ) -> Result<String, ProfileCipherError>
pub fn encrypt_emoji( &self, emoji: String, ) -> Result<Vec<u8>, ProfileCipherError>
pub fn decrypt_emoji( &self, bytes: impl AsRef<[u8]>, ) -> Result<String, ProfileCipherError>
Trait Implementations§
source§impl From<ProfileKey> for ProfileCipher
impl From<ProfileKey> for ProfileCipher
source§fn from(profile_key: ProfileKey) -> Self
fn from(profile_key: ProfileKey) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ProfileCipher
impl RefUnwindSafe for ProfileCipher
impl Send for ProfileCipher
impl Sync for ProfileCipher
impl Unpin for ProfileCipher
impl UnwindSafe for ProfileCipher
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more