import ( "crypto/md5" "encoding/hex" )

func test() { customerKey := "98dad497159e901b45c020d30bff9baf" requestBody := { "agentCode": "HKAD", "agentIDs": "HKAD", "airlineCode": "GA", "limit": 2, "offset": 2 } compressionProvider := new(CompressionProvider) requestStr := hex.EncodeToString(compressionProvider.CompressString(requestBody)) // 1、请求主体内容转换成16进制串 requestBytes := []byte(requestStr) // 2、取请求主体部分的byte customerKeyBytes, _ := hex.DecodeString(customerKey) // 4、对用户KEY解码 signCodeBytes := createSignCode(requestBytes, customerKeyBytes, "MD5") // 5、生成MD5签名 SignCode := hex.EncodeToString(signCodeBytes) }

func createSignCode(text []byte, key []byte, algorithm string) []byte { // MD5生成签名过程 source := make([]byte, len(text)+len(key)) copy(source, text) copy(source[len(text):], key) md := md5.New() md.Write(source) return md.Sum(nil)

public void test throws Exception String customerKey=98dad497159e901b45c020d30bff9baf; String requestBody =n + agentCode HKADn + agentIDs HKADn +

原文地址: https://www.cveoy.top/t/topic/hlSq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录