I'm doing some work with a server side service I don't control. The following works fine in standard C#, but fails (due to missing crypto classes) in Silverlight 2 and 3.
static String DecryptString()
{
s = "<cipherTextHere>";
byte[] toDecryptArray = Convert.FromBase64String(s);
string key = "<key here>";
byte[] keyArray = new byte[key.Length / 2];
for (int i = 0; i < keyArray.Length; i++)
{
keyArray[i] = Convert.ToByte(Convert.ToInt32(key.Substring(i * 2, 2), 16));
}
using (var algo = new System.Security.Cryptography.AesManaged())
{
// The two lines below are the problem
// as SL does not give me the option to select padding or ciphermode
algo.Padding = PaddingMode.PKCS7;
algo.Mode = CipherMode.ECB;
algo.Key = keyArray;
ICryptoTransform cTransform = algo.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(
toDecryptArray, 0, toDecryptArray.Length);
return (UTF8Encoding.UTF8.GetString(resultArray, 0, resultArray.Length));
}
}
What are my options?