Rijndael 填充错误

发布于 2024-10-16 10:14:55 字数 3838 浏览 2 评论 0原文

您好,我正在尝试通过 Rijaendal 加密/解密字符串。 我根本不明白为什么解密会失败。我总是会遇到不正确的填充错误。让我失望的一件事是我的加密结果,我将其作为十六进制数组返回。它的长度为 14 个字节。在我的解密函数中,相同的字节数组在从十六进制转换后最终有 16 个字节。

任何帮助将不胜感激:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace rjandal
{
    class Program
    {
        static void Main(string[] args)
        {
            string DataForEncrypting = "this is a test";

            string key = string.Empty;
            string iv = string.Empty;

            using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
            {
                rmt.KeySize = 256;
                rmt.BlockSize = 128;
                rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
                rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
                rmt.GenerateKey();
                rmt.GenerateIV();
                key = Convert.ToBase64String(rmt.Key);
                iv = Convert.ToBase64String(rmt.IV);
            }

            string encryptedData = _encrypt(DataForEncrypting, key, iv);
            string unencryptedData = _decrypt(key, iv, HexString2Ascii(encryptedData));

            Console.WriteLine(unencryptedData);
            Console.WriteLine(encryptedData);
            Console.ReadKey();
        }

        private static string _encrypt(string value, string key, string initVector)
        {
            byte[] buffer = ASCIIEncoding.ASCII.GetBytes(value);
            byte[] encBuffer;
            using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
            {
                rmt.KeySize = 256;
                rmt.BlockSize = 128;
                rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
                rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
                encBuffer = rmt.CreateEncryptor(Convert.FromBase64String(key),
                    Convert.FromBase64String(initVector)).TransformFinalBlock(buffer, 0, buffer.Length);
            }
            string encryptValue = ConvertToHex(ASCIIEncoding.ASCII.GetString(encBuffer));
            return encryptValue;
        }

        private static string _decrypt(string key, string initVector, string value)
        {
            byte[] hexBuffer = ASCIIEncoding.ASCII.GetBytes(value);
            byte[] decBuffer;
            using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
            {
                rmt.KeySize = 256;
                rmt.BlockSize = 128;
                rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
                rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
                decBuffer = rmt.CreateDecryptor(Convert.FromBase64String(key),
                    Convert.FromBase64String(initVector)).TransformFinalBlock(hexBuffer, 0, hexBuffer.Length);
            }

            return System.Text.ASCIIEncoding.ASCII.GetString(decBuffer);
        } 

        private static string ConvertToHex(string asciiString)
        {
            string hex = "";
            foreach (char c in asciiString)
            {
                int tmp = c;
                hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
            }
            return hex;
        }

        private static string HexString2Ascii(string hexString)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i <= hexString.Length - 2; i += 2)
            {
                sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
            }
            return sb.ToString();
        }

    }
}

Hello I am trying to encrypt / decrypt a string via Rijaendal.
I simply can't figure out why the decryption blows up. I always end up with an incorrect padding error. One thing that throws me off is the result of my encryption which I return as HEX array. It has a length of 14 bytes. In my decryption function, the same byte array ends up having 16 bytes upon conversion from HEX.

Any help would be appreciated:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace rjandal
{
    class Program
    {
        static void Main(string[] args)
        {
            string DataForEncrypting = "this is a test";

            string key = string.Empty;
            string iv = string.Empty;

            using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
            {
                rmt.KeySize = 256;
                rmt.BlockSize = 128;
                rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
                rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
                rmt.GenerateKey();
                rmt.GenerateIV();
                key = Convert.ToBase64String(rmt.Key);
                iv = Convert.ToBase64String(rmt.IV);
            }

            string encryptedData = _encrypt(DataForEncrypting, key, iv);
            string unencryptedData = _decrypt(key, iv, HexString2Ascii(encryptedData));

            Console.WriteLine(unencryptedData);
            Console.WriteLine(encryptedData);
            Console.ReadKey();
        }

        private static string _encrypt(string value, string key, string initVector)
        {
            byte[] buffer = ASCIIEncoding.ASCII.GetBytes(value);
            byte[] encBuffer;
            using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
            {
                rmt.KeySize = 256;
                rmt.BlockSize = 128;
                rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
                rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
                encBuffer = rmt.CreateEncryptor(Convert.FromBase64String(key),
                    Convert.FromBase64String(initVector)).TransformFinalBlock(buffer, 0, buffer.Length);
            }
            string encryptValue = ConvertToHex(ASCIIEncoding.ASCII.GetString(encBuffer));
            return encryptValue;
        }

        private static string _decrypt(string key, string initVector, string value)
        {
            byte[] hexBuffer = ASCIIEncoding.ASCII.GetBytes(value);
            byte[] decBuffer;
            using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
            {
                rmt.KeySize = 256;
                rmt.BlockSize = 128;
                rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
                rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
                decBuffer = rmt.CreateDecryptor(Convert.FromBase64String(key),
                    Convert.FromBase64String(initVector)).TransformFinalBlock(hexBuffer, 0, hexBuffer.Length);
            }

            return System.Text.ASCIIEncoding.ASCII.GetString(decBuffer);
        } 

        private static string ConvertToHex(string asciiString)
        {
            string hex = "";
            foreach (char c in asciiString)
            {
                int tmp = c;
                hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
            }
            return hex;
        }

        private static string HexString2Ascii(string hexString)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i <= hexString.Length - 2; i += 2)
            {
                sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
            }
            return sb.ToString();
        }

    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

〃安静 2024-10-23 10:14:55

基本上,您在文本和数据之间进行了太多转换。例如,看看这个:

string encryptValue = ConvertToHex(ASCIIEncoding.ASCII.GetString(encBuffer));

一旦获得了 ASCII 字符串,为什么需要将转换为十六进制?已经是文字了!但到那时你就已经丢失了数据。除非您真的需要十六进制(在这种情况下,请遵循 Adam 的建议并更改 HexToAscii 方法以采用 byte[] 而不是字符串),您应该只使用 Convert.ToBase64String:

string encryptValue = Convert.ToBase64String(encBuffer);

使用 Convert解密时另一端的.FromBase64String。然后你就可以完全摆脱你的十六进制方法了。

哦,一般来说,我不会使用 Encoding.ASCII 开头...我几乎总是使用 Encoding.UTF8 代替。目前,您将无法(正确)加密任何包含非 ASCII 字符(例如重音符号)的字符串。

这是测试程序的重新调整版本,其中进行了一些更改。请注意,名称“密文”和“纯文本”是在加密方面......它们仍然是二进制数据而不是文本!

using System;
using System.Security.Cryptography;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string DataForEncrypting = "this is a test";

        string key = string.Empty;
        string iv = string.Empty;

        using (RijndaelManaged rmt = new RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = CipherMode.CBC;
            rmt.Padding = PaddingMode.ISO10126;
            rmt.GenerateKey();
            rmt.GenerateIV();
            key = Convert.ToBase64String(rmt.Key);
            iv = Convert.ToBase64String(rmt.IV);
        }

        string encryptedData = _encrypt(DataForEncrypting, key, iv);
        string unencryptedData = _decrypt(key, iv, encryptedData);

        Console.WriteLine(unencryptedData);
        Console.WriteLine(encryptedData);
        Console.ReadKey();
    }

    private static string _encrypt(string value, string key, string initVector)
    {
        using (RijndaelManaged rmt = new RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = CipherMode.CBC;
            rmt.Padding = PaddingMode.ISO10126;
            byte[] plainText = Encoding.UTF8.GetBytes(value);
            byte[] cipherText = rmt.CreateEncryptor(Convert.FromBase64String(key),
                                                    Convert.FromBase64String(initVector))
                                   .TransformFinalBlock(plainText, 0, plainText.Length);
            return Convert.ToBase64String(cipherText);
        }
    }

    private static string _decrypt(string key, string initVector, string value)
    {
        using (RijndaelManaged rmt = new RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = CipherMode.CBC;
            rmt.Padding = PaddingMode.ISO10126;
            byte[] cipherText = Convert.FromBase64String(value);
            byte[] plainText = rmt.CreateDecryptor(Convert.FromBase64String(key),
                                                   Convert.FromBase64String(initVector))
                                  .TransformFinalBlock(cipherText, 0, cipherText.Length);
            return Encoding.UTF8.GetString(plainText);
        }
    }
}

You're doing way too much conversion between text and data, basically. Look at this, for example:

string encryptValue = ConvertToHex(ASCIIEncoding.ASCII.GetString(encBuffer));

Once you've got an ASCII string, why would you need to convert that into hex? It's already text! But by then you'll already have lost the data. Unless you really need it in hex (in which case follow Adam's suggestion and change your HexToAscii method to take a byte[] instead of a string) you should just use Convert.ToBase64String:

string encryptValue = Convert.ToBase64String(encBuffer);

Use Convert.FromBase64String at the other end when decrypting. You can then get rid of your hex methods completely.

Oh, and in general I wouldn't use Encoding.ASCII to start with... I'd almost always use Encoding.UTF8 instead. Currently you'll fail to encrypt (correctly) any strings containing non-ASCII characters such as accents.

Here's a rejigged version of your test program, with a few of those changes made. Note that the names "cipher text" and "plain text" are in terms of encryption... they're still binary data rather than text!

using System;
using System.Security.Cryptography;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string DataForEncrypting = "this is a test";

        string key = string.Empty;
        string iv = string.Empty;

        using (RijndaelManaged rmt = new RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = CipherMode.CBC;
            rmt.Padding = PaddingMode.ISO10126;
            rmt.GenerateKey();
            rmt.GenerateIV();
            key = Convert.ToBase64String(rmt.Key);
            iv = Convert.ToBase64String(rmt.IV);
        }

        string encryptedData = _encrypt(DataForEncrypting, key, iv);
        string unencryptedData = _decrypt(key, iv, encryptedData);

        Console.WriteLine(unencryptedData);
        Console.WriteLine(encryptedData);
        Console.ReadKey();
    }

    private static string _encrypt(string value, string key, string initVector)
    {
        using (RijndaelManaged rmt = new RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = CipherMode.CBC;
            rmt.Padding = PaddingMode.ISO10126;
            byte[] plainText = Encoding.UTF8.GetBytes(value);
            byte[] cipherText = rmt.CreateEncryptor(Convert.FromBase64String(key),
                                                    Convert.FromBase64String(initVector))
                                   .TransformFinalBlock(plainText, 0, plainText.Length);
            return Convert.ToBase64String(cipherText);
        }
    }

    private static string _decrypt(string key, string initVector, string value)
    {
        using (RijndaelManaged rmt = new RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = CipherMode.CBC;
            rmt.Padding = PaddingMode.ISO10126;
            byte[] cipherText = Convert.FromBase64String(value);
            byte[] plainText = rmt.CreateDecryptor(Convert.FromBase64String(key),
                                                   Convert.FromBase64String(initVector))
                                  .TransformFinalBlock(cipherText, 0, cipherText.Length);
            return Encoding.UTF8.GetString(plainText);
        }
    }
}
So要识趣 2024-10-23 10:14:55

您不应该使用 ASCII 字符编码作为中间步骤;您应该将从十六进制转换为 ASCII(然后再返回)的函数更改为从 byte[] 转换为十六进制(然后再返回)。

    private static string ConvertToHex(byte[] data)
    {
        string hex = "";
        foreach (byte b in data)
        {
            hex += b.ToString("X2");
        }
        return hex;
    }

    private static byte[] HexString2ByteArray(string hexString)
    {
        byte[] output = new byte[hexString.Length / 2];

        for (int i = 0; i <= hexString.Length - 2; i += 2)
        {
             output[i/2] = Convert.ToByte(hexString.Substring(i, 2), 16);
        }
        return output;
    }

作为旁注,您是否有理由寻找数组的十六进制表示而不是像 Base64 这样更紧凑的东西?您在示例中使用 Base64 来传输密钥和 IV,所以我只是好奇是什么让您想要在此处以十六进制形式返回加密数据。

无论如何,以下内容应该对您有用:

    private static string _encrypt(string value, string key, string initVector)
    {
        byte[] buffer = Encoding.Unicode.GetBytes(value);
        byte[] encBuffer;
        using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
            rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
            encBuffer = rmt.CreateEncryptor(Convert.FromBase64String(key),
                Convert.FromBase64String(initVector)).TransformFinalBlock(buffer, 0, buffer.Length);
        }
        string encryptValue = ConvertToHex(encBuffer);
        return encryptValue;
    }

    private static string _decrypt(string key, string initVector, string value)
    {
        byte[] hexBuffer = HexString2ByteArray(value);
        byte[] decBuffer;
        using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
            rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
            decBuffer = rmt.CreateDecryptor(Convert.FromBase64String(key),
                Convert.FromBase64String(initVector)).TransformFinalBlock(hexBuffer, 0, hexBuffer.Length);
        }

        return Encoding.Unicode.GetString(decBuffer);
    } 

You shouldn't be using ASCII character encoding as an intermediate step; you should change your functions that go from hex to ASCII (and back again) to go from a byte[] to hex (and back again) instead.

    private static string ConvertToHex(byte[] data)
    {
        string hex = "";
        foreach (byte b in data)
        {
            hex += b.ToString("X2");
        }
        return hex;
    }

    private static byte[] HexString2ByteArray(string hexString)
    {
        byte[] output = new byte[hexString.Length / 2];

        for (int i = 0; i <= hexString.Length - 2; i += 2)
        {
             output[i/2] = Convert.ToByte(hexString.Substring(i, 2), 16);
        }
        return output;
    }

As a side note, is there a reason that you're looking for a hex representation of the array versus something more compact like Base64? You're using Base64 in your example to transfer the key and IV, so I'm just curious about what makes you want to return the encrypted data as hex here.

In any case, here's something that should work for you:

    private static string _encrypt(string value, string key, string initVector)
    {
        byte[] buffer = Encoding.Unicode.GetBytes(value);
        byte[] encBuffer;
        using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
            rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
            encBuffer = rmt.CreateEncryptor(Convert.FromBase64String(key),
                Convert.FromBase64String(initVector)).TransformFinalBlock(buffer, 0, buffer.Length);
        }
        string encryptValue = ConvertToHex(encBuffer);
        return encryptValue;
    }

    private static string _decrypt(string key, string initVector, string value)
    {
        byte[] hexBuffer = HexString2ByteArray(value);
        byte[] decBuffer;
        using (System.Security.Cryptography.RijndaelManaged rmt = new System.Security.Cryptography.RijndaelManaged())
        {
            rmt.KeySize = 256;
            rmt.BlockSize = 128;
            rmt.Mode = System.Security.Cryptography.CipherMode.CBC;
            rmt.Padding = System.Security.Cryptography.PaddingMode.ISO10126;
            decBuffer = rmt.CreateDecryptor(Convert.FromBase64String(key),
                Convert.FromBase64String(initVector)).TransformFinalBlock(hexBuffer, 0, hexBuffer.Length);
        }

        return Encoding.Unicode.GetString(decBuffer);
    } 
So尛奶瓶 2024-10-23 10:14:55

您可以避免解密/加密的问题,并使用 System.Text.Encoding 并避免使用 Base64 编码解决方法,方法是添加一些完全绕过 Microsoft 在 System.Text.Encoding 中不匹配的转换的方法,允许您加密真实的数据内存中的字节没有任何翻译。

由于使用这些,我避免了由 System.Text.Encoding 方法引起的填充错误,也没有使用 Base64 转换。

    private static Byte[] GetBytes(String SomeString)
    {
        Char[] SomeChars = SomeString.ToCharArray();
        Int32 Size = SomeChars.Length * 2;
        List<Byte> TempList = new List<Byte>(Size);
        foreach (Char Character in SomeChars)
        {
            TempList.AddRange(BitConverter.GetBytes(Character));
        }
        return TempList.ToArray();
    }
    private static String GetString(Byte[] ByteArray)
    {
        Int32 Size = ByteArray.Length / 2;
        List<Char> TempList = new List<Char>(Size);
        for (Int32 i = 0; i < ByteArray.Length; i += 2)
        {
            TempList.Add(BitConverter.ToChar(ByteArray, i));
        }
        return new String(TempList.ToArray());
    }

以及它们如何与加密一起使用

    private static String Encrypt(String Test1, Byte[] Key, Byte[] IV)
    {
        Byte[] Encrypted;
        using (AesCryptoServiceProvider AesMan = new AesCryptoServiceProvider())
        {
            AesMan.Mode              = CipherMode.CBC;
            AesMan.Padding           = PaddingMode.ISO10126;
            ICryptoTransform EncThis = AesMan.CreateEncryptor(Key, IV);

            using (MemoryStream msEncrypt = new MemoryStream())
            {
                using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, EncThis, CryptoStreamMode.Write))
                {

                    using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                    {
                        //Write all data to the stream.
                        swEncrypt.Write(Test1);
                    }
                    Encrypted = msEncrypt.ToArray();
                }
            }
        };
        return GetString(Encrypted);
    }

    private static String Decrypt(String Data, Byte[] Key, Byte[] IV)
    {
        String Decrypted;
        using (AesCryptoServiceProvider AesMan = new AesCryptoServiceProvider())
        {
            AesMan.Mode              = CipherMode.CBC;
            AesMan.Padding           = PaddingMode.ISO10126;
            ICryptoTransform EncThis = AesMan.CreateDecryptor(Key, IV);

            using (MemoryStream msDecrypt = new MemoryStream(GetBytes(Data)))
            {
                using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, EncThis, CryptoStreamMode.Read))
                {
                    using (StreamReader srDecrypt = new StreamReader(csDecrypt))
                    {

                        // Read the decrypted bytes from the decrypting stream 
                        // and place them in a string.
                        Decrypted = srDecrypt.ReadToEnd();
                    }
                }
            }
        }
        return Decrypted;
    }

You may avoid the issues with Decypting/Encrypting and usign System.Text.Encoding and avoid using Base64 encoding work around, by adding a few methods that completely bypass microsoft's mismatched conversions in the System.Text.Encoding, by allowing you to encrypt the real bytes in memory without any translations.

Since using these I have avoided padding errors caused by System.Text.Encoding methods, without using the Base64 conversions either.

    private static Byte[] GetBytes(String SomeString)
    {
        Char[] SomeChars = SomeString.ToCharArray();
        Int32 Size = SomeChars.Length * 2;
        List<Byte> TempList = new List<Byte>(Size);
        foreach (Char Character in SomeChars)
        {
            TempList.AddRange(BitConverter.GetBytes(Character));
        }
        return TempList.ToArray();
    }
    private static String GetString(Byte[] ByteArray)
    {
        Int32 Size = ByteArray.Length / 2;
        List<Char> TempList = new List<Char>(Size);
        for (Int32 i = 0; i < ByteArray.Length; i += 2)
        {
            TempList.Add(BitConverter.ToChar(ByteArray, i));
        }
        return new String(TempList.ToArray());
    }

And how they are used with encryption

    private static String Encrypt(String Test1, Byte[] Key, Byte[] IV)
    {
        Byte[] Encrypted;
        using (AesCryptoServiceProvider AesMan = new AesCryptoServiceProvider())
        {
            AesMan.Mode              = CipherMode.CBC;
            AesMan.Padding           = PaddingMode.ISO10126;
            ICryptoTransform EncThis = AesMan.CreateEncryptor(Key, IV);

            using (MemoryStream msEncrypt = new MemoryStream())
            {
                using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, EncThis, CryptoStreamMode.Write))
                {

                    using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                    {
                        //Write all data to the stream.
                        swEncrypt.Write(Test1);
                    }
                    Encrypted = msEncrypt.ToArray();
                }
            }
        };
        return GetString(Encrypted);
    }

    private static String Decrypt(String Data, Byte[] Key, Byte[] IV)
    {
        String Decrypted;
        using (AesCryptoServiceProvider AesMan = new AesCryptoServiceProvider())
        {
            AesMan.Mode              = CipherMode.CBC;
            AesMan.Padding           = PaddingMode.ISO10126;
            ICryptoTransform EncThis = AesMan.CreateDecryptor(Key, IV);

            using (MemoryStream msDecrypt = new MemoryStream(GetBytes(Data)))
            {
                using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, EncThis, CryptoStreamMode.Read))
                {
                    using (StreamReader srDecrypt = new StreamReader(csDecrypt))
                    {

                        // Read the decrypted bytes from the decrypting stream 
                        // and place them in a string.
                        Decrypted = srDecrypt.ReadToEnd();
                    }
                }
            }
        }
        return Decrypted;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文