Module tox::toxencryptsave [−][src]
Tox Encrypt Save (a.k.a. TES) module. Can be used to ecrypt / decrypt data that will be stored on persistent storage. E.g.
use tox::toxencryptsave::*; 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!(plaintext != encrypted.as_slice()); assert_eq!(true, is_encrypted(&encrypted)); // decrypted is same as plaintext assert_eq!(plaintext, pass_decrypt(&encrypted, password).unwrap().as_slice());
Structs
PassKey |
Key and |
Enums
DecryptionError |
Error when trying to decrypt data. |
EncryptionError |
Error encrypting data. |
KeyDerivationError |
Deriving secret key for |
Constants
EXTRA_LENGTH |
Minimal size in bytes of an encrypted file. |
KEY_LENGTH |
Number of bytes in a |
MAGIC_LENGTH |
Length (in bytes) of |
MAGIC_NUMBER |
Bytes used to verify whether given data has been encrypted using TES. |
SALT_LENGTH |
Number of bytes in a |
Functions
get_salt |
Get |
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. |