-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (41 loc) · 854 Bytes
/
main.go
File metadata and controls
49 lines (41 loc) · 854 Bytes
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
package main
import (
"log"
"github.com/vindecodex/encrypt/colors"
"github.com/vindecodex/encrypt/event"
"github.com/vindecodex/encrypt/screens"
"github.com/vindecodex/encrypt/service"
)
func init() {
screens.Clear()
screens.Banner()
}
func main() {
var ans string
for ans != "close" {
screens.Input(&ans)
if event.Listen(&ans) {
continue
}
}
data := "Hello, World! New World! Lorem Ipsum!"
passphrase := "secret"
fileName := "test"
f, err := service.Create(fileName)
if err != nil {
log.Println(err)
}
encryptedData, err := service.Encrypt([]byte(data), passphrase)
if err != nil {
log.Println(err)
}
_, err = service.Write(f, encryptedData)
if err != nil {
log.Println(err)
}
val, err := service.Read("./test.enc", passphrase)
if err != nil {
log.Println(err)
}
colors.SetColorln(val, colors.Green)
}