Skip to content

Commit

Permalink
fixed hash problem
Browse files Browse the repository at this point in the history
  • Loading branch information
reywyn committed Jul 27, 2022
1 parent 113a9cb commit 765510c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions adapter/rest/rest_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ func SendRequest(req *http.Request, v interface{}, opts model.RequestOptions) er
}

func GenerateHash(url, apiKey, secretKey, randomString, body string) string {
hashStr := []string{url, apiKey, secretKey, randomString, body}
hash := strings.Join(hashStr, "")
fmt.Println(hash)
hasher := sha256.New()
hasher.Write([]byte(hash))
hashResult := base64.URLEncoding.EncodeToString(hasher.Sum(nil))
return hashResult
hashStr := strings.Join([]string{url, apiKey, secretKey, randomString, body}, "")
hash := sha256.New()
hash.Write([]byte(hashStr))
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
}

func GenerateRandomString() string {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func main() {
Craftgate := CraftgateClient(apiKey, secretKey, baseURL)

for i := 0; i < 10; i++ {
res, _ := Craftgate.Installment.SearchInstallments(adapter.SearchInstallmentRequest{BinNumber: "487074", Price: 100.00})
res, _ := Craftgate.Installment.SearchInstallments(adapter.SearchInstallmentRequest{BinNumber: "552096", Price: 100.00})
fmt.Println(res)
}

Expand Down

0 comments on commit 765510c

Please sign in to comment.