-
Notifications
You must be signed in to change notification settings - Fork 1
/
aws-kms.go
41 lines (31 loc) · 889 Bytes
/
aws-kms.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
package main
import (
"os"
"github.com/joffotron/aws-kms/kms"
"fmt"
"github.com/voxelbrain/goptions"
)
func main() {
os.Setenv("AWS_SDK_LOAD_CONFIG", "true")
opts := struct {
Help goptions.Help `goptions:"-h, --help, description='Show this help'"`
goptions.Verbs
Encrypt struct {
KeyId string `goptions:"-k, --key-id, description='Key ID to encrypt with', obligatory"`
Input string `goptions:"-i, --input, description='Input data', obligatory"`
} `goptions:"encrypt"`
Decrypt struct {
Input string `goptions:"-i, --input, description='Input data', obligatory"`
} `goptions:"decrypt"`
}{}
goptions.ParseAndFail(&opts)
if len(os.Args) < 2 {
goptions.PrintHelp()
}
if opts.Encrypt.Input != "" {
fmt.Println(kms.Encrypt(opts.Encrypt.Input, opts.Encrypt.KeyId))
}
if opts.Decrypt.Input != "" {
fmt.Println(kms.Decrypt(opts.Decrypt.Input))
}
}