Decrypting AES Base64 Values from ColdFusion in .net

M

majarkus

Hi there,

I am writing an application that is reading encrypted data from a database.
The encrypted data was generated by an application developed in ColdFusion.
The data values were encrypted using the coldfusion 'encrypt' method.

The call to decrypt the values in the coldfusion app is:

decrypt(theValue, theKey, "AES","Base64")

No IV is supplied. (Does this mean the cipher mode is CBC?)

My code below produces a result, however the return values are rubbish.

Is anyone able to provide some advice?

Many thanks,

Mark.


public static string Decrypt1(string TextToBeDecrypted, string key)
{
RijndaelManaged RijndaelCipher = new RijndaelManaged();
RijndaelCipher.KeySize = 128;
RijndaelCipher.BlockSize = 128;
RijndaelCipher.Mode = CipherMode.CBC;
RijndaelCipher.Padding = PaddingMode.None;
RijndaelCipher.Key = Convert.FromBase64String(key);
byte[] EncryptedData = Convert.FromBase64String(TextToBeDecrypted);

ICryptoTransform Decryptor =
RijndaelCipher.CreateDecryptor(RijndaelCipher.Key, RijndaelCipher.Key);

MemoryStream memoryStream = new MemoryStream(EncryptedData);
CryptoStream cryptoStream = new CryptoStream(memoryStream, Decryptor,
CryptoStreamMode.Read);
byte[] PlainText = new byte[EncryptedData.Length];
int DecryptedCount = cryptoStream.Read(PlainText, 0, PlainText.Length);
memoryStream.Close();
cryptoStream.Close();

string DecryptedData = Encoding.Unicode.GetString(PlainText, 0,
DecryptedCount);
return DecryptedData;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,441
Members
47,101
Latest member
DoloresHol

Latest Threads

Top