Function rgp::encrypt

source ·
pub fn encrypt(
    fingerprint: [u8; 32],
    content: Vec<u8>,
    mode: Encrypt<'_>
) -> Result<(Vec<u8>, [u8; 32]), &'static str>
Expand description

signs and encrypts content.

use rgp::{encrypt, Encrypt};

let content = vec![0u8; 1024];

// Dh
let (mut encrypted_content, content_key) = encrypt(
    fingerprint,
    content,
    Encrypt::Dh(sender_priv_key, &recipient_pub_keys)
).unwrap();

// Hmac
let (mut encrypted_content, content_key) = encrypt(
    fingerprint,
    content,
    Encrypt::Hmac(hmac_key, hmac_value, itr)
).unwrap();

// Session
let (mut encrypted_content, content_key) = encrypt(
    fingerprint,
    content,
    Encrypt::Session(session_key)
).unwrap();