feat: add args
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::io::Read;
|
use std::io::{ Read, Write };
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use ring::digest;
|
use ring::digest;
|
||||||
use virt_enclave::sig::*;
|
use virt_enclave::sig::*;
|
||||||
@@ -31,4 +31,15 @@ fn main() {
|
|||||||
println!("File : {}", f);
|
println!("File : {}", f);
|
||||||
println!("Hex : {}", digest_hex);
|
println!("Hex : {}", digest_hex);
|
||||||
println!("Signed: {}", serde_json::to_string(&signed_message).unwrap());
|
println!("Signed: {}", serde_json::to_string(&signed_message).unwrap());
|
||||||
|
|
||||||
|
if let Some(of) = args.next() {
|
||||||
|
if File::open(&of).is_ok() {
|
||||||
|
println!("Output file exists: {}", of);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if let Ok(mut out_file) = File::create(&of) {
|
||||||
|
out_file.write_all(&serde_json::to_string(&signed_message).unwrap().as_bytes()).ok();
|
||||||
|
println!("Write file successed: {}", of);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user