fix README and make decoding more tolerant w.r.t. white space

This commit is contained in:
Sebastian Gesemann
2015-01-29 20:15:10 +01:00
parent f39f129a32
commit 3a9e9d2e59
3 changed files with 12 additions and 9 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
*~

View File

@ -16,15 +16,13 @@ $ echo This is a secret | secretshare -e2,5
2-5-5a/DPbTp0cSaww4Fuckh5wM
```
Decoding a subset (2nd and 3rd) of shares (one share per line):
The parameters following the `-e` option tell `secretshare` to create 5 shares of which 2 will be necessary for decoding.
Decoding a subset of shares (one share per line) can be done like this:
```
$ 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

View File

@ -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;