-
Notifications
You must be signed in to change notification settings - Fork 2
/
s3cr3txGoTest.go
78 lines (69 loc) · 2.19 KB
/
s3cr3txGoTest.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
//"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
)
func main() {
fmt.Println("Hello, Thank you for testing s3cr3tx with Go")
var email string = "[email protected]"
var APIToken string = "bCrCgRrFoMKyw4PDkyoYF8O9PSXDrsKQRuKAueKAmTbDqsOdacOkw6/Dn8Kzw5/DvRTDjuKAusOyWG3DgG1oUMOBOcObfcOLDwpiwo06CcK2W8OHY3vDmkQzwqTCs1Mzwr/Cvg=="
var AuthCode string = "w4zCtm8fH1o7wr/DuB3FoeKAmDtfw5ZvwrLihKLigLA9XcOeMcKtHRYBy4Z5GhTDuMWgwqZoUsOnXR4hCsuG4oChV1HigLDDgMK4w6HFoTbDhlksw7gowrXDhsOMUMOKw4BmFg=="
var baseurl string = "https://s3cr3tx.com/Values"
req, err := http.NewRequest(http.MethodGet, baseurl, nil)
if err != nil {
fmt.Printf("client: could not create request: %s\n", err)
os.Exit(1)
}
req.Header.Set("Content-Type", "text/plain")
req.Header.Set("Accept", "text/plain")
req.Header.Set("Email", email)
req.Header.Set("APIToken", APIToken)
req.Header.Set("AuthCode", AuthCode)
req.Header.Set("EorD", "e")
req.Header.Set("Input", "This is something secret")
client := http.Client{
Timeout: 30 * time.Second,
}
res, err := client.Do(req)
if err != nil {
fmt.Printf("client: error making http request: %s\n", err)
os.Exit(1)
}
resBody, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Printf("client: could not read response body: %s\n", err)
os.Exit(1)
}
fmt.Println("Your encrypted text is : " + string(resBody))
req2, err := http.NewRequest(http.MethodGet, baseurl, nil)
if err != nil {
fmt.Printf("client: could not create request: %s\n", err)
os.Exit(1)
}
req2.Header.Set("Content-Type", "text/plain")
req2.Header.Set("Accept", "text/plain")
req2.Header.Set("Email", email)
req2.Header.Set("APIToken", APIToken)
req2.Header.Set("AuthCode", AuthCode)
req2.Header.Set("EorD", "d")
req2.Header.Set("Input", string(resBody))
client2 := http.Client{
Timeout: 30 * time.Second,
}
res2, err := client2.Do(req2)
if err != nil {
fmt.Printf("client: error making http request: %s\n", err)
os.Exit(1)
}
resBody2, err := ioutil.ReadAll(res2.Body)
if err != nil {
fmt.Printf("client: could not read response body: %s\n", err)
os.Exit(1)
}
fmt.Println("Your decrypted text is : " + string(resBody2))
fmt.Println("Done with s3cr3tx Go Test!")
}