Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C#控制台中解密Xamarin Portable中的PCLCrypto数据_C#_Encryption_Xamarin - Fatal编程技术网

在C#控制台中解密Xamarin Portable中的PCLCrypto数据

在C#控制台中解密Xamarin Portable中的PCLCrypto数据,c#,encryption,xamarin,C#,Encryption,Xamarin,通过按照本教程使用PCLCrypto加密数据: 我唯一的改变是盐,这是我自己设定的: byte[] salt = new byte[16]; salt = Encoding.UTF8.GetBytes("We#@%ds51&s9$$$8"); 我无法在控制台应用程序中解密结果: public static string Decrypt(string text, byte[] key, int keysize = 128, int blocksize =

通过按照本教程使用PCLCrypto加密数据:

我唯一的改变是盐,这是我自己设定的:

byte[] salt = new byte[16];
        salt = Encoding.UTF8.GetBytes("We#@%ds51&s9$$$8");
我无法在控制台应用程序中解密结果:

        public static string Decrypt(string text, byte[] key, int keysize = 128, int blocksize = 128, CipherMode cipher = CipherMode.CBC, PaddingMode padding = PaddingMode.PKCS7)
    {
        AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
        aes.BlockSize = blocksize;
        aes.KeySize = keysize;
        aes.Mode = cipher;
        aes.Padding = padding;

        byte[] iv = new byte[16];
        iv = Encoding.UTF8.GetBytes("We#@%ds51&s9$$$8");

        byte[] src = Convert.FromBase64String(text);
        using (ICryptoTransform decrypt = aes.CreateDecryptor(key, iv))
        {

            byte[] dest = decrypt.TransformFinalBlock(src, 0, src.Length);
            decrypt.Dispose();
            return Encoding.UTF8.GetString(dest);
        }
    }
我做错了什么

谢谢