Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
fix hash key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
3n3a committed Apr 22, 2023
1 parent 049a2ec commit ae9afe3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"bytes"
"crypto/md5"
b64 "encoding/base64"
"encoding/json"
Expand Down Expand Up @@ -124,8 +123,11 @@ func (s *Server) proxyHandler(w http.ResponseWriter, req bunrouter.Request) erro
if err != nil {
fmt.Println("Headers couldnt be converted to JSON.")
}
rawBodyHash := md5.Sum(bytes.Join([][]byte{reqBody, []byte(builtUrl), []byte(req.Method), []byte(headerJSON)}, []byte(" ")))
bodyHash := fmt.Sprintf("%x", rawBodyHash)
rawBodyHash := md5.Sum(reqBody) //, []byte(builtUrl), []byte(req.Method), []byte(headerJSON)}, []byte(" ")))
rawUrlHash := md5.Sum([]byte(builtUrl))
rawHeaderHash := md5.Sum(headerJSON)
reqMethodsHash := md5.Sum([]byte(req.Method))
bodyHash := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%x-%x-%x-%x", rawBodyHash, rawUrlHash, reqMethodsHash, rawHeaderHash))))

// Header Key
headerKey := fmt.Sprintf("%s-header", bodyHash)
Expand Down

0 comments on commit ae9afe3

Please sign in to comment.