pass_encrypt

Function pass_encrypt 

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

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 empty
  • passphrase 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()));