-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (29 loc) · 916 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
package main
import (
"flag"
"log"
"os"
"strings"
)
func main() {
var targetDirectories string
flag.StringVar(&targetDirectories, "target_directories", "", "[required] Comma-separated list of directories to encrypt")
var workerCount int
flag.IntVar(&workerCount, "worker_count", 5, "Number of workers to encrypt/decrpyt with")
var encrypt bool
flag.BoolVar(&encrypt, "encrypt", false, "Pass to encrypt data")
flag.Parse()
dirs := strings.Split(targetDirectories, ", ")
//do nothing unless explicitly requested
if targetDirectories == "" || len(dirs) == 0 {
flag.Usage()
os.Exit(1)
}
cryptor := NewCryptor(WithWorkerCount(workerCount), WithEncryption(encrypt))
cryptor.EnumerateDirectories(dirs)
log.Printf("%s files with chacha20 stream cipher\nkey: %s\n", cryptor.EncryptingOrDecrypting, cryptor.Key)
err := cryptor.ListenAndManageEncryption()
if err != nil {
log.Fatal(err)
}
}