[][src]Function simplecrypt::encrypt

pub fn encrypt(data: &[u8], passphrase: &[u8]) -> Vec<u8>

Encrypt data with an argon2id13 derived key of the given passphrase and a random nonce.

Recturns a Vec of the encrypted data with salt and nonce prepended.

Anatomy of the returned byte vector:

indexusage
0 - 15salt
16 - 39nonce
40 - 55mac
56 -data

Examples

let plaintext = "lord ferris says: you shall not use Go";
let key = "lul no generics";

let encrypted_data_with_nonce = encrypt(plaintext.as_bytes(), key.as_bytes());