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::new(profile_key);
let encrypted = cipher.encrypt_name(&name, &mut rng).unwrap();
let decrypted = cipher.decrypt_name(&encrypted).unwrap().unwrap();
assert_eq!(decrypted.as_ref(), name);
Implementations§
Source§impl ProfileCipher
impl ProfileCipher
pub fn new(profile_key: ProfileKey) -> Self
pub fn into_inner(self) -> ProfileKey
pub fn decrypt( &self, encrypted_profile: SignalServiceProfile, ) -> Result<Profile, ProfileCipherError>
pub fn decrypt_avatar( &self, bytes: &[u8], ) -> Result<Vec<u8>, ProfileCipherError>
pub fn encrypt_name<'inp, R: Rng + CryptoRng>( &self, name: impl Borrow<ProfileName<&'inp str>>, csprng: &mut R, ) -> Result<Vec<u8>, ProfileCipherError>
pub fn decrypt_name( &self, bytes: impl AsRef<[u8]>, ) -> Result<Option<ProfileName<String>>, ProfileCipherError>
pub fn encrypt_about<R: Rng + CryptoRng>( &self, about: String, csprng: &mut R, ) -> Result<Vec<u8>, ProfileCipherError>
pub fn decrypt_about( &self, bytes: impl AsRef<[u8]>, ) -> Result<String, ProfileCipherError>
pub fn encrypt_emoji<R: Rng + CryptoRng>( &self, emoji: String, csprng: &mut R, ) -> Result<Vec<u8>, ProfileCipherError>
pub fn decrypt_emoji( &self, bytes: impl AsRef<[u8]>, ) -> Result<String, ProfileCipherError>
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
§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> 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>
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