I'm trying to use a custom IV for encryption but it results in a ciphertext with padding of As in the beginning like
AAAAAAAAAAAAAAAAAAAAACbglBtdgH3ajX1jgkOaVAsFYyDxRRI=
I followed the sample implementation at https://gist.github.com/manishtpatel/8222606 with a few changes. The go playground to run and test https://play.golang.org/p/2rS6zBwbnF
My code is at
https://play.golang.org/p/qlx_cU0VPQ
Here is the encrypt function for references as well
func Encrypt(key []byte, text string) string {
// key := []byte(keyText)
plaintext := []byte(text)
block, err := aes.NewCipher(key)
if err != nil {
panic(err)
}
// The IV needs to be unique, but not secure. Therefore it's common to
// include it at the beginning of the ciphertext.
ciphertext := make([]byte, aes.BlockSize+len(plaintext))
iv := commonIV
stream := cipher.NewCFBEncrypter(block, iv)
stream.XORKeyStream(ciphertext[aes.BlockSize:], plaintext)
// convert to base64
return base64.URLEncoding.EncodeToString(ciphertext)
}