-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (52 loc) · 1.38 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"flag"
"fmt"
"github.com/notwithering/memory"
)
var (
confirmKey bool
noDecrypt bool
noEdit bool
noEncrypt bool
)
func main() {
var keyFlag string
flag.BoolVar(&confirmKey, "confirm-key", confirmKey, "")
flag.BoolVar(&confirmKey, "c", confirmKey, "")
flag.StringVar(&keyFlag, "key", keyFlag, "")
flag.StringVar(&keyFlag, "k", keyFlag, "")
flag.BoolVar(&noDecrypt, "no-decrypt", noDecrypt, "")
flag.BoolVar(&noEdit, "no-edit", noEdit, "")
flag.BoolVar(&noEncrypt, "no-encrypt", noEncrypt, "")
flag.Usage = func() {
fmt.Println("Usage: evi [options...] <file>")
fmt.Println(" -c, -confirm-key Program asks for key twice")
fmt.Println(" -h, -help Show this help menu")
fmt.Println(" -k, -key Preset the encryption key")
fmt.Println(" -no-decrypt Stop the program from decrypting the file")
fmt.Println(" -no-edit Stop the program from opening the editor")
fmt.Println(" -no-encrypt Stop the program from re-encrypting the file")
}
flag.Parse()
if !noEdit {
getEditor()
}
getFilename()
if keyFlag == "" {
chooseKey()
} else {
key = hash([]byte(keyFlag))
memory.Zero(&keyFlag)
}
if !noDecrypt {
decrypt()
}
if !noEdit {
openEditor()
}
// TODO: instead of only re-encryptying after the editor closes: re-encrypt after anything is written to the file.
if !noEncrypt {
encrypt()
}
}