C# Triple DES encryption to decrypt Informix ENCRYPT_TDES function

776 Views Asked by At

I have data from an Informix database that has a column with data encrypted using the Informix function ENCRYPT_TDES. The data was imported into SQL SERVER 2008 and I no longer have access to a running instance of Informix. I need to write a C# or VB.NET function for decrypting that data. Anyone know how to write a C# function to decrypt it?

1

There are 1 best solutions below

0
On

The way that the data is stored for encrypted data with ENCRYPT_TDES or ENCRYPT_AES is not documented, and is not obvious. It includes control information for which algorithm was used (so you normally decrypt the data server-side with DECRYPT_CHAR() or DECRYPT_BINARY(), without specifying which algorithm was used), the hint (if present), and the IV that was used, all encoded with a Base-64 encoding. The hint is essentially freely available (anyone can use the GETHINT() function on the data to get the hint, without knowing the right password) but it is stored lightly encrypted with a fixed key.

So, yes, you could in principle write C# code to decrypt the data, but you would have to be ready to deal with either Triple-DES (TDES) or AES (128-bit) encryption, and you'd have to understand the internals of the data format.