Request header | Description | Note | Example |
Content-Type | application/json | - | - |
TC-Timestamp | Timestamp in milliseconds. | This field is provided by Super App as a Service (SAS). | 1735293931220 |
TC-Signature | Signature string. | This field is provided by Super App as a Service (SAS) and is a hex-encoded string based on AES ECB encryption of the TC-Timestamp value string. The secret key is referenced in the Configuration Management . | xxx |
func TestGenerateSignature(t *testing.T) {// test datasecretKey := "MBMIvsoijBSTqLPoCHYinLXKvlaCKfev"timestamp := fmt.Sprintf("%v", time.Now().UnixMilli())encryptBytes, err := EncryptECB([]byte(timestamp), []byte(secretKey))if err != nil {fmt.Println(err)}signature := hex.EncodeToString(encryptBytes)fmt.Println(signature)}func EncryptECB(plaintext, key []byte) ([]byte, error) {block, err := aes.NewCipher(key)if err != nil {return nil, errors.Errorf(fmt.Sprintf("Error: NewCipher(%d bytes) = %s", len(key), err))}padded := PKCS7Padding(plaintext, block.BlockSize())ciphertext := make([]byte, len(padded))for bs, be := 0, block.BlockSize(); bs < len(padded); bs, be = bs+block.BlockSize(), be+block.BlockSize() {block.Encrypt(ciphertext[bs:be], padded[bs:be])}return ciphertext, nil}func PKCS7Padding(ciphertext []byte, blockSize int) []byte {padding := blockSize - len(ciphertext)%blockSizepadtext := bytes.Repeat([]byte{byte(padding)}, padding)return append(ciphertext, padtext...)}
Feedback