func encryptQuery(query string) (string, error) { encryptedQuery := util.EncryptBase64(util.EncryptRSA([]byte(query))) if encryptedQuery == EmptyString { return EmptyString, EncryptionFailed } return url.QueryEscape(encryptedQuery), nil }
func encrytQuery(query string, appId string) (string, error) { encrypted := make([]string, 0) encrypted = append(encrypted, util.ParamNameParams, SymbolEqual) encryptedParams := util.EncryptBase64(util.EncryptRSA([]byte(query))) if encryptedParams == EmptyString { return EmptyString, EncryptionFailed } encrypted = append(encrypted, url.QueryEscape(encryptedParams)) encrypted = append(encrypted, SymbolAnd, util.ParamNameAppId, SymbolEqual, appId) encrypted = append(encrypted, SymbolAnd, util.ParamNameCharset, SymbolEqual, util.DefaultCharset) encrypted = append(encrypted, SymbolAnd, util.ParamNameSign, SymbolEqual) signature := util.EncryptBase64(util.SignRSA([]byte(query), crypto.MD5)) if signature == EmptyString { return EmptyString, EncryptionFailed } encrypted = append(encrypted, url.QueryEscape(signature)) encryptedQueryString := strings.Join(encrypted, EmptyString) return encryptedQueryString, nil }