I have a ColdFusion page that decrypts some data from another application. The ColdFusion code is pretty simple:
decrypt(theString,encryptKey,algorithmType,encodeType)
The algorithm type is RC4 and the encode type is hex. For whatever reason I'm having quite a bit of trouble getting this to work in .net. Are there any resources available for this kind of thing, or is there a fairly straightforward answer?
Update:
I've started by using an RC4 class found here: RC4 Encryption in C#. Although I've changed the encoding to Ascii, the results still are not matching.
public static class RC4
{
   public static string Encrypt(string key, string data)
   {
      Encoding unicode = Encoding.Unicode;
      return Convert.ToBase64String(Encrypt(unicode.GetBytes(key), unicode.GetBytes(data)));
   }
   public static string Decrypt(string key, string data)
   {
      Encoding unicode = Encoding.Unicode;
      return unicode.GetString(Encrypt(unicode.GetBytes(key), Convert.FromBase64String(data)));
   }
   public static byte[] Encrypt(byte[] key, byte[] data)
   {
      return EncryptOutput(key, data).ToArray();
   }
   public static byte[] Decrypt(byte[] key, byte[] data)
   {
      return EncryptOutput(key, data).ToArray();
   }
   private static byte[] EncryptInitalize(byte[] key)
   {
      byte[] s = Enumerable.Range(0, 256)
        .Select(i => (byte)i)
        .ToArray();
      for (int i = 0, j = 0; i < 256; i++)
      {
         j = (j + key[i % key.Length] + s[i]) & 255;
         Swap(s, i, j);
      }
      return s;
   }
   private static IEnumerable<byte> EncryptOutput(byte[] key, IEnumerable<byte> data)
   {
      byte[] s = EncryptInitalize(key);
      int i = 0;
      int j = 0;
      return data.Select((b) =>
      {
         i = (i + 1) & 255;
         j = (j + s[i]) & 255;
         Swap(s, i, j);
         return (byte)(b ^ s[(s[i] + s[j]) & 255]);
      });
   }
   private static void Swap(byte[] s, int i, int j)
   {
      byte c = s[i];
      s[i] = s[j];
      s[j] = c;
   }
}
 
     
    