# Encryption & Decryption in Ax 2012

**URL:** <https://www.dynamicsuser.net/t/encryption-decryption-in-ax-2012/54792>\
**Category:** User Forum\
**Created:** [September 10, 2014, 4:30am UTC](https://www.dynamicsuser.net/t/encryption-decryption-in-ax-2012/54792 "2014-09-10T04:30:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![csrocker](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@csrocker](https://www.dynamicsuser.net/u/csrocker)\
**Post date:** [September 10, 2014, 4:30am UTC](https://www.dynamicsuser.net/t/encryption-decryption-in-ax-2012/54792/1 "2014-09-10T04:30:54Z")

</div>

Hi All,

I have written two seperate methods for both Encrypt & Decrypt.

Encryption is going on correctly, and then storing the encrypted value in a string field in a Table.

But for decrypting, I have written this piece of code mentioned below:

CryptoApi cryptoApi = new CryptoApi(99999);

Container cont;

container cont1;

Password password;

Tablename tableName;

cont1 = conIns(cont1, 1, BinData::stringToData(tableName::find().UserPassword));

if (!cont1)

{

return ‘’;

}

cont = ContainerClass::blob2Container(CryptoApi.decrypt(tinCont));

return con2Str(cont);

but seems like it is not working properly and thorwing error “Problem in Encrypt and Decrypt”.

Please guide me on this problem

I am using Ax 2012 version.

Thanks

Pranav Gupta

---

<div class="post-metadata">

**Author:** ![csrocker](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@csrocker](https://www.dynamicsuser.net/u/csrocker)\
**Post date:** [September 10, 2014, 8:53am UTC](https://www.dynamicsuser.net/t/encryption-decryption-in-ax-2012/54792/2 "2014-09-10T08:53:31Z")

</div>

Hi All,

Finally get the solution.

Now instead of storing the encrypted value in a string field, I am directly storing it in the container type field.

Now the decryption functionality is working properly.

Thanks & Regards

Pranav Gupta
