mirror of
https://github.com/mii443/RustySecrets.git
synced 2025-12-03 03:08:24 +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
|
/target
|
||||||
|
*~
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -16,15 +16,13 @@ $ echo This is a secret | secretshare -e2,5
|
|||||||
2-5-5a/DPbTp0cSaww4Fuckh5wM
|
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
|
$ echo -e "2-2-HkctX9qblUhW7EGutTxNKvs \n 2-3-O94PSafi5nzDilhF3htZBQ0" | secretshare -d
|
||||||
2-1-cfFLZV0QABT0RmqOCFVxW/w
|
This is a secret
|
||||||
2-2-HkctX9qblUhW7EGutTxNKvs
|
|
||||||
2-3-O94PSafi5nzDilhF3htZBQ0
|
|
||||||
2-4-wDbhK8mQovAPpRfu0u41yPU
|
|
||||||
2-5-5a/DPbTp0cSaww4Fuckh5wM
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Building
|
# 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();
|
let mut shares: Vec<(u8,Vec<u8>)> = Vec::new();
|
||||||
for line in stdin.lines() {
|
for line in stdin.lines() {
|
||||||
let line = try!(line);
|
let line = try!(line);
|
||||||
let parts: Vec<_> = line.split('-').collect();
|
let parts: Vec<_> = line.trim().split('-').collect();
|
||||||
let (k, n, raw) = match
|
let (k, n, raw) = match
|
||||||
Some(parts).and_then(|p| {
|
Some(parts).and_then(|p| {
|
||||||
if p.len() != 3 { None } else { Some(p) }
|
if p.len() != 3 { None } else { Some(p) }
|
||||||
@@ -214,13 +214,17 @@ fn main() {
|
|||||||
to generate. 1 <= K <= N <= 255", "K,N");
|
to generate. 1 <= K <= N <= 255", "K,N");
|
||||||
let opt_matches = match opts.parse(args.tail()) {
|
let opt_matches = match opts.parse(args.tail()) {
|
||||||
Ok(m) => m,
|
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") {
|
if args.len() < 2 || opt_matches.opt_present("h") {
|
||||||
println!(
|
println!(
|
||||||
"The program secretshare is an implementation of Shamir's secret sharing scheme.\n\
|
"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!("{}", opts.usage("Usage: secretshare [options]"));
|
||||||
println!("Input is read from STDIN and output is written to STDOUT.");
|
println!("Input is read from STDIN and output is written to STDOUT.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user