# 未加密(该代码为示例代码,企业须填写企业对应信息)
curl --location --request POST 'https://www.feishu.cn/approval/openapi/v2/external/instanceOperate' \
--header 'Content-Type: application/json' \
--data-raw '{
"action_type": "APPROVE",
"action_context": "12345",
"user_id": "b85s39b",
"approval_code": "A3895051-9B16-4ABA-B785-AD2986177BB1",
"instance_id": "people_1234",
"task_id": "step1",
"reason": "ok",
"attachments": [
{
"file_type": "IMAGE",
"file_name": "1.png",
"file_size": 12345,
"url": "https://sf3-cn.feishucdn.com/obj/lark-approval-attachment/image/20200512/413342ae-957f-4c6f-8d06-7dea05875d8b"
}
],
"token": "aaaaa"
}'
# 加密
curl --location --request POST 'https://www.feishu.cn/approval/openapi/v2/external/instanceOperate' \
--header 'Content-Type: application/json' \
--data-raw '{
"encrypt": "=sfasdfasfsdafasfaf="
}'
# 解密 示例代码
package decrypt
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"fmt"
"io"
)
func CBCDecrypter(decryptContent string, keyStr string) ([]byte, error) {
buf, err := base64.StdEncoding.DecodeString(decryptContent)
if err != nil {
return nil, err
}
key := sha256.Sum256([]byte(keyStr))
if len(buf)%aes.BlockSize != 0 {
return nil, fmt.Errorf("plaintext is not a multiple of the block size")
}
block, err := aes.NewCipher(key[:sha256.Size])
if err != nil {
return nil, err
}
ciphertext := make([]byte, aes.BlockSize+len(buf))
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return nil, err
}
mode := cipher.NewCBCDecrypter(block, iv)
mode.CryptBlocks(ciphertext[aes.BlockSize:], buf)
ciphertext = ciphertext[32:]
plain := standardizeDataDe(ciphertext)
return plain, nil
}
func standardizeDataDe(origData []byte) []byte {
length := len(origData)
unpadding := int(origData[length-1])
if unpadding > length {
return nil
}
return origData[:(length - unpadding)]
}