Expand description
E.g.
use tox_encryptsave::*;
let plaintext = b"pls no encrypt";
let password = b"123456";
// to encrypt data
let encrypted = pass_encrypt(plaintext, password)
.expect("Failed to encrypt >.<\"");
// confirm that the data is encrypted
assert_ne!(plaintext, encrypted.as_slice());
assert!(is_encrypted(&encrypted));
// decrypted is same as plaintext
assert_eq!(plaintext,
pass_decrypt(&encrypted, password).unwrap().as_slice());
Structs§
- PassKey
- Key and
Salt
that are used to encrypt/decrypt data.
Enums§
- Decryption
Error - Error when trying to decrypt data.
- Encryption
Error - Error encrypting data.
- KeyDerivation
Error - Deriving secret key for
PassKey
.
Constants§
- EXTRA_
LENGTH - Minimal size in bytes of an encrypted file.
- KEY_
LENGTH - Length in bytes of the key used to encrypt/decrypt data.
Number of bytes in a
PrecomputedKey
. - MAGIC_
LENGTH - Length (in bytes) of
MAGIC_NUMBER
. - MAGIC_
NUMBER - Bytes used to verify whether given data has been encrypted using TES.
- SALT_
LENGTH - Length in bytes of the salt used to encrypt/decrypt data.
Number of bytes in a
Salt
.
Functions§
- get_
salt - Get
Salt
from data encrypted with TES. - is_
encrypted - Check if given piece of data appears to be encrypted by TES.
- pass_
decrypt - Try to decrypt given TES data with provided passphrase.
- pass_
encrypt - Try to encrypt given data with provided passphrase.