-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
42 lines (31 loc) · 842 Bytes
/
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
package main
import (
"fmt"
"os"
"github.com/waldirborbajr/kvstok/cmd"
"github.com/waldirborbajr/kvstok/internal/kvpath"
security "github.com/waldirborbajr/kvstok/internal/secutiry"
)
var (
hasPub = true
hasPriv = true
)
func main() {
home := kvpath.GetKVHomeDir()
pub := home + "/.config/kvstok/kvstok.pub"
priv := home + "/.config/kvstok/kvstok.priv"
if _, err := os.Stat(pub); err != nil {
hasPub = false
}
if _, err := os.Stat(priv); err != nil {
hasPriv = false
}
// Generete PRIV/PUB RSA Key
if !hasPub && !hasPriv {
fmt.Println("Generating RSA priv/pub keys pairing")
privateKey, publicKey := security.RSA_GenerateKey(4096)
_ = os.WriteFile(pub, []byte(security.PublicKeyToBytes(publicKey)), 0600)
_ = os.WriteFile(priv, []byte(security.PrivateKeyToBytes(privateKey)), 0600)
}
cmd.Execute()
}