pub fn decrypt(cyphertext: &[u8], keypair: &Keypair) -> Option<Vec<u8>>Expand description
Attempt to decrypt a private-box message, using your secret key.
If you were an intended recipient then the decrypted message is
returned as Some(Vec<u8>). If it was not for you, then None
will be returned.
ยงExample
use private_box::{encrypt, decrypt};
use ssb_crypto::Keypair;
fn main() {
let msg = "hello!".as_bytes();
let alice = Keypair::generate();
let bob = Keypair::generate();
let recps = [alice.public, bob.public];
let cypher = encrypt(msg, &recps);
let alice_result = decrypt(&cypher, &alice);
let bob_result = decrypt(&cypher, &bob);
assert_eq!(&alice_result.unwrap(), &msg);
assert_eq!(&bob_result.unwrap(), &msg);
}