-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (46 loc) · 1.18 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
//
// Copyright (c) 2023 Joel Strasser <[email protected]>
//
// Licensed under the EUPL-1.2 license.
//
// For the full license text consult the 'LICENSE' file from the repository.
//
package main
import (
"enka/enka_decryption"
"enka/enka_encryption"
"flag"
"fmt"
"log"
"os"
)
var commands = map[string]func([]string, *log.Logger, *log.Logger){
"encrypt": enka_encryption.Encrypt,
"decrypt": enka_decryption.Decrypt,
}
var help bool
var errorLog = log.New(os.Stderr, "[enka] ", 0)
var outLog = log.New(os.Stdout, "[enka] ", 0)
func main() {
flag.BoolVar(&help, "help", false, "Show the global help")
flag.Parse()
if len(flag.Args()) == 0 {
globalUsage(os.Args[0])
globalHelp()
os.Exit(1)
}
command, ok := commands[flag.Args()[0]]
if !ok {
globalUsage(os.Args[0])
os.Exit(1)
}
command(flag.Args()[1:], outLog, errorLog)
}
func globalUsage(executable string) {
fmt.Printf("Usage: %s [ --help ] encrypt [ --algo ] [ --kdf ] < --key > [ --salt ] < --text > [ --verbose ] | decrypt < --key > < --string >\n", executable)
}
func globalHelp() {
fmt.Println("Help:")
fmt.Println(" encrypt The encryption module")
fmt.Println(" decrypt The decryption module")
}