使用RijndaelManaged解密清单资源流时出错

时间:2012-01-06 12:54:59

标签: c# encryption

我有这段代码:

    private byte[] c1(string a, string b)
    {
        RijndaelManaged managed = new RijndaelManaged
        {Key = Convert.FromBase64String(a), IV = Convert.FromBase64String(b)};

        Stream manifestResourceStream = base.GetType().Assembly.GetManifestResourceStream("file.Assembly");
        CryptoStream stream5 = new CryptoStream(manifestResourceStream, managed.CreateDecryptor(), CryptoStreamMode.Read);
        byte[] buffer = new byte[manifestResourceStream.Length];
        stream5.Read(buffer, 0, buffer.Length);
        stream5.Close();
        manifestResourceStream.Close();
        return buffer;
    }

在放入一些随机基础64键或IV之后我收到错误... 这是错误行:

        CryptoStream stream5 = new CryptoStream(manifestResourceStream, managed.CreateDecryptor(), CryptoStreamMode.Read);

错误消息(System.NullReferenceException未处理)

是否由错误的Key和IV引起? 或者它是文件中的问题?

0 个答案:

没有答案