HighTechTalks DotNet Forums  

Decrypting ColdFusion encrypted strings in C#/.Net 1.1

Dotnet Security microsoft.public.dotnet.security


Discuss Decrypting ColdFusion encrypted strings in C#/.Net 1.1 in the Dotnet Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
majarkus@gmail.com
 
Posts: n/a

Default Decrypting ColdFusion encrypted strings in C#/.Net 1.1 - 06-08-2007 , 05:15 AM






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;

}







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.