Decrypting AES Base64 Values from ColdFusion in .net

Discussion in 'ASP .Net Security' started by majarkus, Jun 8, 2007.

  1. majarkus

    majarkus Guest

    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;

    }
     
    majarkus, Jun 8, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marshall Dudley

    encrypting and decrypting with perl

    Marshall Dudley, Jan 27, 2005, in forum: Perl
    Replies:
    1
    Views:
    769
    Brian McCauley
    Jan 27, 2005
  2. Mike Driscoll

    AES decrypting in Python

    Mike Driscoll, Oct 7, 2009, in forum: Python
    Replies:
    3
    Views:
    4,086
    Stef Mientki
    Oct 8, 2009
  3. OTS
    Replies:
    0
    Views:
    221
  4. Phil C.
    Replies:
    2
    Views:
    527
    Phil C.
    Jul 19, 2005
  5. Nate Wiger

    New AES gem available -- fast-aes

    Nate Wiger, Jan 20, 2010, in forum: Ruby
    Replies:
    3
    Views:
    225
    Pål Bergström
    Jul 1, 2010
Loading...

Share This Page