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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// SMITH ( // /
// main ( )/ /
// by salade )(/ /
// ________________ ( /) /
// ()__)____________))))) :^} /
package main
import (
"encoding/json"
"io/ioutil"
"fmt"
"log"
"os"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
)
// #include "../csrc/smith.h"
// #cgo LDFLAGS: -lsmith -L../
import "C"
type Config struct {
Public_key string
Secret_key string
Mirror string
}
func main() {
fmt.Println("Welcome, traveller, my name is " + Styles.colorGreen + C.GoString(C.mr_smith()) + Styles.colorReset +
"\nI will try to help you get the bag...")
// get user config from json file
config_path := "./config.json"
for i, a := range os.Args[1:] {
if a == "-c" || a == "--config" {
config_path = os.Args[i + 2]
}
}
config_content, err := ioutil.ReadFile(config_path)
if err != nil {
log.Fatal("error: config file not found", err)
}
var config Config
err = json.Unmarshal(config_content, &config)
if err != nil {
log.Fatal("error: marshall() ", err)
}
make_ui()
fmt.Println("\n" +
Styles.colorBlue + "public_key: " + Styles.colorReset + config.Public_key + "\n" +
Styles.colorBlue + "secret_key: " + Styles.colorReset + config.Secret_key + "\n" +
Styles.colorBlue + "mirror: " + Styles.colorReset + config.Mirror)
// make request body and sign it
body := make_body("qwe", "qwe", "qwe")
fmt.Println(body)
signature := sign_request(body, config.Secret_key)
fmt.Println("[" + signature + "]")
}
func make_ui() error {
if err := ui.Init(); err != nil {
log.Fatal("error: failed to initialize termui", err)
}
p:= widgets.NewParagraph()
p.Text = "hello"
p.SetRect(0, 0, 25, 5)
ui.Render(p)
for e := range ui.PollEvents() {
if e.Type == ui.KeyboardEvent {
return nil
}
}
return nil
}
|