1 回答
TA贡献1777条经验 获得超3个赞
请使用相同的密钥“7061737323313233”。
使用相同的静脉注射。
十二月全文。
func main() {
d2, err := Decrypt("VMlk9qzp2BKZi5wZjlzst2iwEre0uD/VHVc6xm2bhXY=", "7061737323313233")
if err != nil {
log.Println(err)
return
}
fmt.Println(d2)
}
// Decrypt decrypts cipher text string into plain text string
func Decrypt(encrypted string, CIPHER_KEY string) (string, error) {
key := []byte(CIPHER_KEY)
cipherText, _ := base64.StdEncoding.DecodeString(encrypted) ////hex.DecodeString(encrypted)
block, err := aes.NewCipher(key)
if err != nil {
panic(err)
}
if len(cipherText) < aes.BlockSize {
panic("cipherText too short")
}
// iv := cipherText[:aes.BlockSize]
iv := []byte("7061737323313233")
cipherText = cipherText[:]
if len(cipherText)%aes.BlockSize != 0 {
panic("cipherText is not a multiple of the block size")
}
// cipherText, _ = Pad(cipherText, aes.BlockSize)
mode := cipher.NewCBCDecrypter(block, iv)
mode.CryptBlocks(cipherText, cipherText)
return fmt.Sprintf("%s", cipherText), nil
}
- 1 回答
- 0 关注
- 133 浏览
添加回答
举报