I'm currently developing a Xamarin Forms Project and I need to use a few encryption methods that would normally be available through namespace System.Security.Cryptography namely RSACryptoServiceProvider. So far I have been using PCLCrypto nuget package to use other methods such MD5 hashing but I haven't figured out how to use RSA specifically. I was also wondering if it would be better to implement those methods directly on each native Project instead and then use them on the shared one instead of using the nuget.
Any thoughts on this? If someone could point me towards some documentation for PCLCrypto equivalent to what I need it would be fine as well, I just need some lights on this concern and some clarification since I've read some other questions but there isn't really a consensus.
Because the Nuget package for Cryptography is not PCL friendly, you might want to utilize Xamarin.Forms DependencyService. You can implement those Crypto methods natively and just call the actual implementations via the DependencyService.
Create an interface in your PCL (e.g. ICrypto).
Create a method in that interface that, for example, validates a password (e.g. bool PasswordValid).
Add the Nuget package for System.Security.Cryptography to your native project.
Create a class in your native code that will implement that interface (e.g. Crypto_Android) and have an implementation for the method (e.g. bool PasswordValid)
Call this code from your PCL via DependencyService. The syntax would be something like this:
bool valid = DependencyService.Get< ICrypto >().PasswordValid(password);
NOTE: For the code on actual Cryptography you can check the PCLCrypto Github link provided above by Tifa.
A simple DependencyService example can be found here.