- base64 & aes 加密
base64.StdEncoding.DecodedLen
returns the maximum length in bytes of the decoded data 导致密文长度异常解密失败
// base64编码
cipherTextBase64 := make([]byte, base64.StdEncoding.EncodedLen(len(cipherText)))
base64.StdEncoding.Encode(cipherTextBase64, cipherText)
// base64解码
cipherText := make([]byte, base64.StdEncoding.DecodedLen(len(cipherTextWithBase64)))
_, err := base64.StdEncoding.Decode(cipherText, cipherTextWithBase64)
// 如何解决
n, err := base64.StdEncoding.Decode(cipherText, cipherTextWithBase64)
cipherText[:n]
有疑问加站长微信联系(非本文作者)