Documentation
¶
Index ¶
- Constants
- func Decrypt(encryptedText string, keyContent string) (string, error)
- func DecryptData(text string, key string) string
- func Encrypt(plainText string, keyContent string) (string, error)
- func EncryptData(text string, key string) string
- func GenerateHMac(message string, key string) (string, error)
- func GenerateTokenTypeH(requestData string, key string, dtNowWithTimezone time.Time, ...) (string, string, error)
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5Unpadding(origData []byte) []byte
- func PrepareRequest(hashInfo map[string]string, body, key string, isEncryptBody bool) string
- func RequestTokenTypeC(tokenReferenceData string, key string, dtNowWithTimezone time.Time, ...) (string, error)
- func VerifyHMac(message string, hMac string, key string) (bool, error)
- type DataPrepare
- type KeyInfor
- type MetaPrepare
- type ResponsePreparePayload
Constants ¶
const ( LIBVERSION = "1.0.0" ErrFatal = "fatal error" ErrInvalidHeaderSignatur = "invalid header signature" )
LIBVERSION is version of library
Variables ¶
This section is empty.
Functions ¶
func DecryptData ¶
DecryptData encrypt text with key input
func EncryptData ¶
EncryptData encrypt text with key input
func GenerateTokenTypeH ¶ added in v1.0.14
func GenerateTokenTypeH(requestData string, key string, dtNowWithTimezone time.Time, isRequestDataEncrypt bool) (string, string, error)
GenerateTokenTypeH use for Host to Host request short life time 60 secconds params: requestData type: string description: string or json string to generate token type H with request data params: key type: string description: key content get from T2P params: dtNowWithTimezone type: time.Time description: current date time with server time zone eg. "Asia/Bangkok" params: isRequestDataEncrypt type: bool description: will requestData be encrypted or plaintext for secure use encrypt
func PKCS5Padding ¶
PKCS5Padding is a function for padding string
func PKCS5Unpadding ¶
PKCS5Unpadding is a function for unpadding string
func PrepareRequest ¶
PrepareRequest is a function for preparing requests to call APIs
func RequestTokenTypeC ¶ added in v1.0.14
func RequestTokenTypeC(tokenReferenceData string, key string, dtNowWithTimezone time.Time, authUrl string) (string, error)
RequestTokenTypeC use for Host to Host request short life time 60 secconds params: tokenReferenceData type: string description: short reference for tracing if needed params: key type: string description: key content get from T2P params: dtNowWithTimezone type: time.Time description: current date time with server time zone eg. "Asia/Bangkok" params: authUrl type: string description: T2P authen server URL (UAT) `https://test-api-authen.t2p.co.th/authen/v1/clientToken/generate`, (PROD) `https://api-authen.t2p.co.th/authen/v1/clientToken/generate`
Types ¶
type DataPrepare ¶
DataPrepare data part
type KeyInfor ¶
type KeyInfor struct { KeyContents string `json:"keyContents"` KeyAuthorize map[string][]string `json:"keyAuthorize"` RequireInfo map[string]string `json:"requireInfo"` TokenTimeout map[string]int `json:"tokenTimeout"` HostTokenTimeZone string `json:"hostTokenTimeZone"` }
KeyInfor key infor to redis
type MetaPrepare ¶
type MetaPrepare struct { Language string `json:"language"` ResponseCode int `json:"responseCode"` ResponseMessage string `json:"responseMessage"` Version string `json:"version"` }
MetaPrepare meta part
type ResponsePreparePayload ¶
type ResponsePreparePayload struct { Meta MetaPrepare `json:"meta"` Data DataPrepare `json:"data"` }
ResponsePreparePayload main payload