I'm working in the iPad version of my app and I have a function in what I use AesCryptoServiceProvider
for example the following lines
using (AesCryptoServiceProvider aesProvider = new AesCryptoServiceProvider())
{
setAesProviderSettings(aesProvider);
result = aesProvider.CreateEncryptor().TransformFinalBlock(plainBytes, 0, plainBytes.Length);
}
It works in my Android app(MonDroid) and in a .NET(WPF) application but in iOS I got this error;
Error 5 The type or namespace name 'AesCryptoServiceProvider' could not be found (are you missing a using directive or an assembly reference?)
The function is in my core project and I use the project linker to reference it in the iPad project and also I use project linker in the Android version, of course in the three platforms is the same file with all the references that it need. I use Xamarin with Visual Studio 12.
Use the factory method Aes.Create ()
and your code will be more portable across different .NET versions/platforms. E.g.
using (var aesProvider = Aes.Create ()) {
setAesProviderSettings(aesProvider);
result = aesProvider.CreateEncryptor().TransformFinalBlock(plainBytes, 0, plainBytes.Length);
}
In Xamarin.iOS it will return AesManaged
(from System.Core.dll
) but, in reality, it's calling Apple CommonCrypto (it's not a managed implementation) which can be hardware accelerated (depending on your devices).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With