Skip to main content

encrypt

Function encrypt 

Source
pub fn encrypt(data: &[u8], passphrase: &str) -> Result<Vec<u8>, Error>
Expand description

Encrypt data using AES-256-GCM with PBKDF2 key derivation

§Arguments

  • data - The plaintext data to encrypt
  • passphrase - The passphrase to derive the encryption key from

§Returns

Base64-encoded encrypted data with format: salt || nonce || ciphertext

§Example

use shipper_encrypt::encrypt;

let data = b"Secret message";
let passphrase = "my-passphrase";

let encrypted = encrypt(data, passphrase).expect("encryption failed");
// encrypted is base64-encoded and can be safely stored as text