pub struct Packet { /* fields omitted */ }
Converts serializable data to and from websafe strings.
Construct a Packet with the given master key. Must be 64 hex characters.
Returns an error if there is a problem with the key. The error kind can be:
use simple_secrets::Packet;
let sender = Packet::new("<64-char hex string master key (32 bytes, 256 bits)>".to_string());
Turn a Rust type into an encrypted packet. This object will
possibly be deserialized in a different programming
environment—it should be JSON-like in structure.
Returns a SimpleSecretsError
if there is a problem at any point
in the process of serializing, encrypting, authenticating, and serializing
the data. The various scenarios are described in the doc for that error type.
use simple_secrets::Packet;
let sender = Packet::new("<64-char hex string master key (32 bytes, 256 bits)>".to_string());
let packet = sender.pack("this is a secret message").unwrap();
assert_eq!(packet, "Qr4m7AughkcQIRqQvlyXiB67EwHdBf5n9J\
D2s_Z9NpO4ksPGvLYjNbDm3HRzvFXFSpV2\
IqDQw_LTamndMh2c7iOQT0lSp4LstqJPAt\
oQklU5sb7JHYyTOuf-6W-q7W8gAnq1wCs5");
Turn an encrypted packet into a Rust structure. This
object possibly originated in a different programming
environment—it should be JSON-like in structure.
Returns a SimpleSecretsError
if there is a problem at any point
in the process of decoding, verifying, decrypting, and deserializing
the data. The various scenarios are described in the doc for that
error type.
use simple_secrets::Packet;
let sender = Packet::new("<64-char hex string master key (32 bytes, 256 bits)>".to_string());
let packet = "OqlG6KVMeyFYmunboS3HIXkvN_nXKTxg2y\
NkQydZOhvJrZvmfov54hUmkkiZCnlhzyrl\
wOJkbV7XnPPbqvdzZ6TsFOO5YdmxjxRksZ\
meIhbhLaMiDbfsOuSY1dBn_ZgtYCw-FRIM".to_string();
let secret_message = sender.unpack(packet)?;
Encrypt a packet into raw bytes. This allows the caller
to issue app-specific typesafe serialization calls beforehand.
Decrypt a packet into raw bytes. This allows the caller
to issue app-specific typesafe deserialization calls later.
Construct a Packet with the given 256-bit master key.
Ensure that sensitive data is removed from memory
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static