init
This commit is contained in:
commit
79a13d3941
6 changed files with 2009 additions and 0 deletions
18
examples/basic.rs
Normal file
18
examples/basic.rs
Normal 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}");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue