コード例 #1
0
func signQuery(query string) (string, error) {
	signature := util.EncryptBase64(util.SignRSA([]byte(query), crypto.SHA1))
	if signature == EmptyString {
		return EmptyString, EncryptionFailed
	}
	return url.QueryEscape(signature), nil
}
コード例 #2
0
func encryptQuery(query string) (string, error) {
	encryptedQuery := util.EncryptBase64(util.EncryptRSA([]byte(query)))
	if encryptedQuery == EmptyString {
		return EmptyString, EncryptionFailed
	}
	return url.QueryEscape(encryptedQuery), nil
}
コード例 #3
0
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
}