crypto

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiSign

func ApiSign(data map[string]string, priKey string) (error, string)

ApiSign generate data sign

@param data api param data
@param priKey rsa private key
@return error
@return string

func ApiVerifySign

func ApiVerifySign(data map[string]string, pubKey string, signStr string) error

ApiVerifySign verify sign

@param data api response data
@param pubKey public key
@param signStr sign string
@return error

func CallbackServerGenResponseSign

func CallbackServerGenResponseSign(resBody interface{}, priKey string) (resBodyWithSign interface{}, err error)

CallbackServerGenResponseSign shop callback server generate sign for the response to the platform notify

@param resBody the http body response to te platform notify request, type can be []byte, string or struct.
@param priKey rsa private key, generated by shop client.
@return newResBody new response body with a sign field.
 if reqBody type is []byte, return newReqBody type is []byte.
 if reqBody type is string, return newReqBody type is string.
 if reqBody type is struct, return newReqBody type is map[string]interface{}.

func CallbackServerGenResponseSignOnly

func CallbackServerGenResponseSignOnly(resBodyData interface{}, priKey string) (sign string, err error)

CallbackServerGenResponseSignOnly shop callback server generate sign string for the response body

@param resBodyData the response body 'data' field value, the type should be one of struct, struct point or map[string]interface{}, witch can be marshaled safely.
@param priKey rsa private key, generated by shop client.
@return sign new crypto string

func CallbackServerVerifyRequestSign

func CallbackServerVerifyRequestSign(reqBody interface{}, pubKey string) error

CallbackServerVerifyRequestSign shop callback server verify the request sign sent by platform.

@param reqBody, http request body, type can be []byte, string or struct.
@param pubKey, rsa public key, provided by platform.

func ParseJsonToClassMap

func ParseJsonToClassMap(jsonStr string) (m map[string]string)

ParseJsonToClassMap convert json string to map[string]string

func ParseObjectToClassMap

func ParseObjectToClassMap(v interface{}) map[string]string

ParseObjectToClassMap convert struct to map[string]string

func ShopClientGenPlatformRequestSign

func ShopClientGenPlatformRequestSign(reqBody interface{}, priKey string) (newReqBody interface{}, err error)

ShopClientGenPlatformRequestSign shop client generate sign for request body before send request to platform

@param reqBody http request body going to send, type can be []byte, string or struct.
@param priKey shop client rsa private key.
@return newReqBody if reqBody type is []byte, return newReqBody type is []byte.
 if reqBody type is string, return newReqBody type is string.
 if reqBody type is struct, return newReqBody type is map[string]interface{}.

func ShopClientVerifyPlatformResponseSign

func ShopClientVerifyPlatformResponseSign(resBody interface{}, pubKey string) error

ShopClientVerifyPlatformResponseSign shop client verify the 'sign' of platform response

@param resBody http response body received, type can be []byte, string or struct.
@param pubKey rsa public key , provided by platform.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL