pub struct CryptoSym;Trait Implementations§
Source§impl BlockCipher for CryptoSym
impl BlockCipher for CryptoSym
Source§fn encrypt_message(
signer_sk: &[u8; 32],
receiver_pk: &[u8; 32],
msg: &[u8],
) -> Result<Vec<u8>>
fn encrypt_message( signer_sk: &[u8; 32], receiver_pk: &[u8; 32], msg: &[u8], ) -> Result<Vec<u8>>
Encode a message text with AES-GCM algorithm using the signer’s the PrivateKey and receiver’s PublicKey.
§Inputs
-
signer_sk: The signer’s private key. -
receiver_pk: The receiver’s public key. -
msg: Message to encrypt.
§Returns
A Result whose okay value is an encrypt message Vec<u8> or whose error value
is an failure::Error describing the error that occurred.
Source§fn decrypt_message(
receiver_sk: &[u8; 32],
signer_pk: &[u8; 32],
enc_msg: &[u8],
) -> Result<Vec<u8>>
fn decrypt_message( receiver_sk: &[u8; 32], signer_pk: &[u8; 32], enc_msg: &[u8], ) -> Result<Vec<u8>>
Decrypt a message text with AES-GCM algorithm using the receiver’s the PrivateKey and signer’s PublicKey.
§Inputs
-
receiver_sk: The receiver’s private key. -
signer_pk: The signer’s public key. -
enc_msg: Message encrypted.
§Example
ⓘ
use std::str::FromStr;
use symbol_crypto_core::{PrivateKey, PublicKey,decrypt_message };
let receiver_sk = PrivateKey::from_str("A22A4BBF126A2D7D7ECE823174DFD184C5DE0FDE4CB2075D30CFA409F7EF8908").unwrap();
let signer_pk = PublicKey::from_str("3FD283D8543C12B81917C154CDF4EFD3D48E553E6D7BC77E29CB168138CED17D").unwrap();
let encrypt_text_vec = [
125, 59, 126, 248, 124, 129, 157, 100, 111, 84, 49, 163, 111, 68, 22, 137, 75, 132, 135,
217, 251, 158, 115, 74, 226, 172, 200, 208, 33, 183, 110, 103, 107, 170, 52, 174, 192, 110,
164, 44, 77, 69, 203, 48, 43, 17, 206, 143, 154, 155, 231, 72, 28, 24, 20, 241, 234, 202,
184, 66,
];
let decrypted_text = decrypt_message( receiver_sk.as_fixed_bytes(), signer_pk.as_fixed_bytes(), &encrypt_text_vec).unwrap();§Returns
A Result whose okay value is an decrypted message Vec<u8> or whose error value
is an failure::Error describing the error that occurred.
Auto Trait Implementations§
impl Freeze for CryptoSym
impl RefUnwindSafe for CryptoSym
impl Send for CryptoSym
impl Sync for CryptoSym
impl Unpin for CryptoSym
impl UnwindSafe for CryptoSym
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