[TOC]
异构系统基于RESTful接口加解密
环境:GO1.8/JDK1.8/Python2.7
GO示例
package common
import (
"crypto/aes"
"crypto/cipher"
"bytes"
"fmt"
"encoding/base64"
)
var key = []byte("B31F2A75FBF94099")
var iv = []byte("1234567890123456")
type AES_CBC struct {
}
func Encrypt(origData []byte) (string, error) {
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}
blockSize := block.BlockSize()
origData = PKCS5Padding(origData, blockSize)
// origData = ZeroPadding(origData, block.BlockSize())
blockMode := cipher.NewCBCEncrypter(block, iv)
crypted := make([]byte, len(origData))
blockMode.CryptBlocks(crypted