encryption.go
func EncryptAES(key []byte, plaintext []byte) []byte {
	block := AES.GetCypher(key)
	defer AES.ReturnCypher(key, block)

	// 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 := ciphertext[:aes.BlockSize]
	if _, err := io.ReadFull(rand.Reader, iv); err != nil {
		panic(err)
	}

	stream := cipher.NewCFBEncrypter(block, iv)
	stream.XORKeyStream(ciphertext[aes.BlockSize:], plaintext)

	return ciphertext
}
func EncryptAES(key []byte, plaintext []byte) []byte {
	block := AES.GetCypher(key)
	defer AES.ReturnCypher(key, block)

	// 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 := ciphertext[:aes.BlockSize]
	if _, err := io.ReadFull(rand.Reader, iv); err != nil {
		panic(err)
	}

	stream := cipher.NewCFBEncrypter(block, iv)
	stream.XORKeyStream(ciphertext[aes.BlockSize:], plaintext)

	return ciphertext
}
func EncryptAES ( key [ ] byte , plaintext [ ] byte ) [ ] byte { block := AES . GetCypher ( key ) defer AES . ReturnCypher ( key , block ) // 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 := ciphertext [ : aes . BlockSize ] if _ , err := io . ReadFull ( rand . Reader , iv ) ; err != nil { panic ( err ) } stream := cipher . NewCFBEncrypter ( block , iv ) stream . XORKeyStream ( ciphertext [ aes . BlockSize : ] , plaintext ) return ciphertext }
// EncryptAES encrypts plaintext using AES with the given key.
// key should be either 16, 24, or 32 bytes to select
// AES-128, AES-192, or AES-256.
// plaintext must not be shorter than key.
EncryptAES encrypts plaintext using AES with the given key . key should be either 16 24 or 32 bytes to select AES - 128 AES - 192 or AES - 256 . plaintext must not be shorter than key .