-
Notifications
You must be signed in to change notification settings - Fork 3
/
sssaas-cli.go
52 lines (44 loc) · 1.06 KB
/
sssaas-cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"github.com/SSSaaS/sssa-golang"
"flag"
"fmt"
"log"
"strings"
)
func main() {
create := flag.Bool("create", false, "create shares from a secret")
minimum := flag.Int("minimum", 3, "minimum shares required to recreate secret")
shares := flag.Int("shares", 4, "total shares to create (shares >= minimum)")
secret := flag.String("secret", "Hello, World!", "secret to share")
combine := flag.Bool("combine", false, "combines shares into a secret")
raw := flag.String("secrets", "", "comma separated list of shared secrets")
flag.Parse()
switch {
case *create == *combine:
flag.Usage()
case *create:
if *minimum > *shares {
flag.Usage()
} else {
values, err := sssa.Create(*minimum, *shares, *secret)
if err != nil {
log.Println(err)
}
for i := range values {
fmt.Println(values[i])
}
}
default:
if *raw == "" {
flag.Usage()
} else {
secrets := strings.Split(*raw, ",")
value, err := sssa.Combine(secrets)
if err != nil {
log.Println(err)
}
fmt.Println("Secret: ", value)
}
}
}