Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Working around crypto restrictions in Silverlight 2 or 3
2 replies. Latest Post by clint1222 on June 2, 2009.
(0)
aronchick
Member
0 points
3 Posts
06-02-2009 4:06 PM |
I'm doing some work with a server side service I don't control. The following works fine in standard C#, but fails to compile (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()) { 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?
jackbond
Contributor
2820 points
725 Posts
06-02-2009 8:29 PM |
Which crypto classes are missing? System.Security.Cryptography.AesManaged is in there.
clint1222
Participant
1542 points
216 Posts
06-02-2009 9:11 PM |
The SymmetricAlgorithm.Padding and SymmetricAlgorithm.Mode aren't available in Silverlight 2.