My PCL project does not support System.Security.Cryptography , I am trying to use 3DES algorithm for encryption and decryption. But PCL Crypto does not support 3DES. what is the work around in this scenario.
@Maharshi.5212 - Here is an example of someone self implementing on Windows Phone 7 but should be easily enough implemented in PCL or at least natively per platform. https://gist.github.com/amrishodiq/1622737
However if 3DES is just because of a personal preference or outdated security recommendations, AES is generally recommended over 3DES.
Can i use the PCl crypto library in the normal asp.net app . The encryption is getting done in the server. My app needs to decrypt it.
There is a code recipe i found in the PCl crypto library.
byte[] keyMaterial;
byte[] data;
var provider = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
var key = provider.CreateSymmetricKey(keyMaterial);
byte[] iv = null; // this is optional, but must be the same for both encrypting and decrypting
byte[] cipherText = WinRTCrypto.CryptographicEngine.Encrypt(key, data, iv);
byte[] plainText = WinRTCrypto.CryptographicEngine.Decrypt(key, cipherText, iv);
Posts
If your Platform specific project's version of .NET supports 3DES then you can write an abstraction that you expose to your PCL.
See https://developer.xamarin.com/guides/xamarin-forms/dependency-service/ for examples
@Maharshi.5212 - Here is an example of someone self implementing on Windows Phone 7 but should be easily enough implemented in PCL or at least natively per platform. https://gist.github.com/amrishodiq/1622737
However if 3DES is just because of a personal preference or outdated security recommendations, AES is generally recommended over 3DES.
Can i use the PCl crypto library in the normal asp.net app . The encryption is getting done in the server. My app needs to decrypt it.
There is a code recipe i found in the PCl crypto library.
byte[] keyMaterial;
byte[] data;
var provider = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
var key = provider.CreateSymmetricKey(keyMaterial);
byte[] iv = null; // this is optional, but must be the same for both encrypting and decrypting
byte[] cipherText = WinRTCrypto.CryptographicEngine.Encrypt(key, data, iv);
byte[] plainText = WinRTCrypto.CryptographicEngine.Decrypt(key, cipherText, iv);
Can i do it in a normal C# project?
Can i use PCLcrypto in a normal c# application?
Hi,
I have written this code for pcl encryption .
static class Program
{
static void Main(string[] args)
{
But I cannot change the length of the sample string. What shall i do in this scenario?
This work for me ...
public static string SymmetricEncrypt(this string plaintext)
{
string data = Convert.ToBase64String(Encoding.UTF8.GetBytes(plaintext));
string key = "AAECAwQFBgcICQoLDA0ODw==";
byte[] keyBuffer = Convert.FromBase64String(key);
byte[] plainTextBuffer = Convert.FromBase64String(data);