0

下面的代码有什么问题?CryptoStream产生零字节数据。

public void Decrypt(Stream theInput, Stream theOutput, string theKey)
{
    Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(theKey, salt);
    RijndaelManaged RM = new RijndaelManaged();
    RM.Mode = CipherMode.ECB;

    using (CryptoStream cs = new CryptoStream(theOutput, RM.CreateDecryptor(pdb.GetBytes(32), pdb.GetBytes(16)), CryptoStreamMode.Write))
    {
        int bufferLen = 4096;
        byte[] buffer = new byte[bufferLen];
        int bytesRead;
        do
        {
            bytesRead = theInput.Read(buffer, 0, bufferLen);
            cs.Write(buffer, 0, bytesRead);
        } while (bytesRead != 0);
    }
}
4

0 回答 0