mirror of
https://github.com/mii443/RustySecrets.git
synced 2025-08-22 16:25:32 +00:00
fix README and make decoding more tolerant w.r.t. white space
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/target
|
||||
*~
|
||||
|
@ -20,11 +20,7 @@ Decoding a subset (2nd and 3rd) of shares (one share per line):
|
||||
|
||||
```
|
||||
$ echo -e "2-2-HkctX9qblUhW7EGutTxNKvs \n 2-3-O94PSafi5nzDilhF3htZBQ0" | secretshare -d
|
||||
2-1-cfFLZV0QABT0RmqOCFVxW/w
|
||||
2-2-HkctX9qblUhW7EGutTxNKvs
|
||||
2-3-O94PSafi5nzDilhF3htZBQ0
|
||||
2-4-wDbhK8mQovAPpRfu0u41yPU
|
||||
2-5-5a/DPbTp0cSaww4Fuckh5wM
|
||||
This is a secret
|
||||
```
|
||||
|
||||
# Building
|
||||
|
10
src/main.rs
10
src/main.rs
@ -144,7 +144,7 @@ fn read_shares() -> IoResult<(u8, Vec<(u8,Vec<u8>)>)> {
|
||||
let mut shares: Vec<(u8,Vec<u8>)> = Vec::new();
|
||||
for line in stdin.lines() {
|
||||
let line = try!(line);
|
||||
let parts: Vec<_> = line.split('-').collect();
|
||||
let parts: Vec<_> = line.trim().split('-').collect();
|
||||
let (k, n, raw) = match
|
||||
Some(parts).and_then(|p| {
|
||||
if p.len() != 3 { None } else { Some(p) }
|
||||
@ -214,13 +214,17 @@ fn main() {
|
||||
to generate. 1 <= K <= N <= 255", "K,N");
|
||||
let opt_matches = match opts.parse(args.tail()) {
|
||||
Ok(m) => m,
|
||||
Err(f) => panic!(f.to_string())
|
||||
Err(f) => {
|
||||
drop(writeln!(&mut stderr, "Error: {}", f));
|
||||
os::set_exit_status(1);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if args.len() < 2 || opt_matches.opt_present("h") {
|
||||
println!(
|
||||
"The program secretshare is an implementation of Shamir's secret sharing scheme.\n\
|
||||
It is applied byte-wise within a finite field for arbitraty long secrets.\n");
|
||||
It is applied byte-wise within a finite field for arbitrarily long secrets.\n");
|
||||
println!("{}", opts.usage("Usage: secretshare [options]"));
|
||||
println!("Input is read from STDIN and output is written to STDOUT.");
|
||||
return;
|
||||
|
Reference in New Issue
Block a user