Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update s3cr3txGoTest.go #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 37 additions & 36 deletions s3cr3txGoTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
//"crypto/tls"
"bufio"
"fmt"
"io/ioutil"
"net/http"
Expand All @@ -11,11 +12,34 @@ import (

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"
fmt.Println("Please enter your input: ")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
err := scanner.Err()
if err != nil {
fmt.Printf("client: could not read the input: %s\n", err)
}
var strInput = scanner.Text()
fmt.Println("Please enter 'e' to encrypt or 'd' to decrypt: ")
scanner2 := bufio.NewScanner(os.Stdin)
scanner2.Scan()
err2 := scanner2.Err()
if err != nil {
fmt.Printf("client: could not read the input: %s\n", err2)
}
var strDirection = scanner2.Text()
if strInput != "" && strDirection != "" {
var strOutput = io(strDirection, strInput)
fmt.Println(strOutput)
}

fmt.Println("Done with s3cr3tx Go Test!")
}
func io(strDirection string, strInput string) string {
var email string = "[email protected]" //"[email protected]"
var APIToken string = "yourS3cr3txAPIToken"
var AuthCode string = "yourS3cr3txAuthCode"
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)
Expand All @@ -26,8 +50,8 @@ func main() {
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")
req.Header.Set("EorD", strDirection)
req.Header.Set("Input", strInput)
client := http.Client{
Timeout: 30 * time.Second,
}
Expand All @@ -43,36 +67,13 @@ func main() {
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)
if strDirection == "e" {
var strOutput = "Your encrypted text is : " + string(resBody)
return strOutput
}
resBody2, err := ioutil.ReadAll(res2.Body)
if err != nil {
fmt.Printf("client: could not read response body: %s\n", err)
os.Exit(1)
if strDirection == "d" {
var strOutput = "Your decrypted text is : " + string(resBody)
return strOutput
}

fmt.Println("Your decrypted text is : " + string(resBody2))

fmt.Println("Done with s3cr3tx Go Test!")
return ""
}