[−][src]Function tox_encryptsave::pass_encrypt
pub fn pass_encrypt(
data: &[u8],
passphrase: &[u8]
) -> Result<Vec<u8>, EncryptionError>
Try to encrypt given data with provided passphrase.
Note that passphrase
memory is not being zeroed after it has been
used. Code that provides passphrase
should take care of zeroing that
memory.
Fails when:
data
is emptypassphrase
is empty- deriving key failed (can happen due to OOM)
E.g.
use tox_encryptsave::*; // empty data assert_eq!(pass_encrypt(&[], &[0]), Err(EncryptionError::Null)); // empty passphrase assert_eq!(pass_encrypt(&[0], &[]), Err(KeyDerivationError::Null.into()));