This commit is contained in:
JMARyA 2025-04-29 20:43:42 +02:00
commit 79a13d3941
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 2009 additions and 0 deletions

18
examples/basic.rs Normal file
View file

@ -0,0 +1,18 @@
use sage::{Identity, PersonaIdentity};
fn main() {
let i = Identity::new();
let receiver = i.public().enc_key().unwrap();
let e = i.encrypt("Hello World!".as_bytes(), &receiver);
println!("Cipher: {e:?}");
let pk_of_sender = i.public().sign_key().unwrap();
let d = i.decrypt(&e, &pk_of_sender).unwrap();
println!("Message made at {}", d.timestamp);
let ds = String::from_utf8(d.payload).unwrap();
println!("Clear: {ds}");
}