Skip to content

Commit

Permalink
fix go warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Cheong committed Jul 29, 2023
1 parent e5c7577 commit a0369fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
5 changes: 2 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net/url"
"os"
Expand Down Expand Up @@ -57,7 +56,7 @@ type HARData struct {
}

func readHAR() {
file, err := ioutil.ReadFile("chatgpt.har")
file, err := os.ReadFile("chatgpt.har")
if err != nil {
fmt.Println(err)
return
Expand Down Expand Up @@ -88,7 +87,7 @@ func readHAR() {
arkHeader = make(http.Header)
for _, h := range arkReq.Request.Headers {
// arkHeader except cookie & content-length
if strings.EqualFold(h.Name, "content-length") == false && strings.EqualFold(h.Name, "cookie") == false && strings.HasPrefix(h.Name, ":") == false {
if !strings.EqualFold(h.Name, "content-length") && !strings.EqualFold(h.Name, "cookie") && !strings.HasPrefix(h.Name, ":") {
arkHeader.Set(h.Name, h.Value)
if strings.EqualFold(h.Name, "user-agent") {
bv = h.Value
Expand Down
6 changes: 6 additions & 0 deletions crypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func Decrypt(data string, key string) string {

func AesDecrypt(baseText string, password string) (string, error) {
encBytes, err := base64.StdEncoding.DecodeString(baseText)
if err != nil {
return "", err
}
var encData encryptionData
err = json.Unmarshal(encBytes, &encData)
if err != nil {
Expand All @@ -145,6 +148,9 @@ func AesDecrypt(baseText string, password string) (string, error) {
return "", err
}
salt, err := hex.DecodeString(encData.S)
if err != nil {
return "", err
}
key, iv, err := DefaultEvpKDF([]byte(password), salt)
if err != nil {
return "", err
Expand Down
10 changes: 0 additions & 10 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"math/rand"
"net/url"
"os"
"strings"
Expand Down Expand Up @@ -74,12 +73,3 @@ func getRequestId(sessionId string) string {
pwd := fmt.Sprintf("REQUESTED%sID", sessionId)
return Encrypt(`{"sc":[147,307]}`, pwd)
}

func randomHex(length int) string {
chars := []rune("0123456789abcdef")
var b strings.Builder
for i := 0; i < length; i++ {
b.WriteRune(chars[rand.Intn(len(chars))])
}
return b.String()
}

0 comments on commit a0369fd

Please sign in to comment.