pub fn decrypt(
ciphertext: impl AsRef<[u8]>,
passphrase: impl AsRef<[u8]>
) -> Result<Vec<u8>>Available on crate feature
alloc only.Expand description
Decrypts ciphertext and into a newly allocated Vec.
This is a convenience function for using Decryptor::new and
Decryptor::decrypt_to_vec.
Errors
Returns Err if any of the following are true:
ciphertextis shorter than 156 bytes.- The magic number is invalid.
- The version number is the unrecognized abcrypt version number.
- The Argon2 parameters are invalid.
- The Argon2 context is invalid.
- The MAC (authentication tag) of the header is invalid.
- The MAC (authentication tag) of the ciphertext is invalid.
Examples
let data = b"Hello, world!\n";
let ciphertext = include_bytes!("../tests/data/data.txt.abcrypt");
let passphrase = "passphrase";
let plaintext = abcrypt::decrypt(ciphertext, passphrase).unwrap();