# Encrypting data from the Hashicorp Vault aes256-gcm96 by exported key

**URL:** <https://discuss.hashicorp.com/t/encrypting-data-from-the-hashicorp-vault-aes256-gcm96-by-exported-key/44639>\
**Category:** Vault\
**Created:** [September 22, 2022, 5:44am UTC](https://discuss.hashicorp.com/t/encrypting-data-from-the-hashicorp-vault-aes256-gcm96-by-exported-key/44639 "2022-09-22T05:44:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahan.sharma](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/rahan.sharma/32/15966_2.png) [@rahan.sharma](https://discuss.hashicorp.com/u/rahan.sharma)\
**Post date:** [September 22, 2022, 5:44am UTC](https://discuss.hashicorp.com/t/encrypting-data-from-the-hashicorp-vault-aes256-gcm96-by-exported-key/44639/1 "2022-09-22T05:44:33Z")

</div>

Hi Vault Community,

I am trying to encrypt the data outside of vault. I am aware there is a way to do using data key from vault. But What I am doing can be broken down into the below steps.

1. Export key from the vault
2. Use the key to encrypt/decrypt the data.

Now the problem is my golang code is complaining the key is 44 byte. It is expecting it to be 32 bytes.  
On using 32 characters from the key it works. Can someone help what is the issue and I am doing wrong.

Thanks in Advance.

---

<div class="post-metadata">

**Author:** ![jeffsanicola](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jeffsanicola/32/18651_2.png) [@jeffsanicola](https://discuss.hashicorp.com/u/jeffsanicola)\
**Post date:** [September 22, 2022, 11:49am UTC](https://discuss.hashicorp.com/t/encrypting-data-from-the-hashicorp-vault-aes256-gcm96-by-exported-key/44639/2 "2022-09-22T11:49:21Z")

</div>

Based on the sample response in the [API docs](https://www.vaultproject.io/api-docs/secret/transit#sample-response-3) it looks like the keys are base64 encoded. You may need to decode them before use in your code.

---

<div class="post-metadata">

**Author:** ![rahan.sharma](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/rahan.sharma/32/15966_2.png) [@rahan.sharma](https://discuss.hashicorp.com/u/rahan.sharma)\
**Post date:** [September 29, 2022, 11:05am UTC](https://discuss.hashicorp.com/t/encrypting-data-from-the-hashicorp-vault-aes256-gcm96-by-exported-key/44639/3 "2022-09-29T11:05:12Z")

</div>

Already doing so, but not working
