Crate serialize_with_password

Source
Expand description

§Serialize_with_password

Small crate that adds additional layer on top of the serde crate. This crate allows to encrypt serialized data with password

§Examples

§Serialization with password

use serialize_with_password::{serialize, is_encrypted, deserialize};
 
let example_data = b"some data";
let password = b"password";
let encrypted = serialize(example_data, password).unwrap();
 
assert_ne!(example_data.to_vec(), encrypted);
assert!(is_encrypted(&encrypted).expect("Correctly encrypted data always will return Ok(bool) for is_encrypted"));
assert_eq!(example_data.to_vec(), deserialize(&encrypted, password).expect("Correct password"));
assert!(deserialize(&encrypted, b"bacPass").is_err());

§Serialize without password

use serialize_with_password::{serialize_no_pass, is_encrypted, deserialize, deserialize_no_pass};
 
let example_data = b"some data";
let encoded = serialize_no_pass(example_data);
 
assert!(!is_encrypted(&encoded).unwrap());
assert_eq!(example_data.to_vec(), deserialize_no_pass(&encoded).unwrap());
assert_eq!(example_data.to_vec(), deserialize(&encoded, b"Any password").unwrap());

Structs§

ChaCha20Error
Error type.

Enums§

Argon2Error
Error type.
Error

Functions§

deserialize
Decrypt data with given password
deserialize_no_pass
Deserialize data
is_encrypted
Returns whether data is encrypted For random non empty data returns random bool value
serialize
Encrypt data using password
serialize_no_pass
Serialize data without password

Type Aliases§

Result