DES加密代码
FileStream fsInput = new FileStream(sInputFilename,FileMode.Open,FileAccess.Read);FileStream fsEncrypted = new FileStream(sOutputFilename,FileMode.Create,FileAccess.Write);
DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
DES.Key =Encoding.UTF8.GetBytes(sKey);
DES.IV = Encoding.UTF8.GetBytes(sKey);
ICryptoTransform desencrypt = DES.CreateEncryptor();
CryptoStream cryptostream = new CryptoStream(fsEncrypted,desencrypt, CryptoStreamMode.Write); byte[] bytearrayinput = new byte[fsInput.Length];
fsInput.Read(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Close();
fsInput.Close();
fsEncrypted.Close();
解密与此类似,但结果不支持中文,如何改写才能支持中文?
THANKS

解决方案 »

  1.   

    我用“中文ABC”测试(加解密)没问题....
    因为是byte操作,应该和中英文无关的
      

  2.   

    我测试解密后显示结果为:ABC
    "中文"没有显示出来,什么原因呢
      

  3.   

    单单是文件操作,是没问题的,单看两个生成的文件,不显示
    除非你在页面加入汉字,如往.write("中文Abc")中文Abc变成Abc,一般是utf8的缘故,看你的代码和web.config设置
      

  4.   

    前几天看到一个同样的问题,解码的时候用Encoding.Default就可以了.
    帖子在这儿,已经解决.里面有详细代码:
    http://expert.csdn.net/Expert/topic/1237/1237771.xml?temp=.1235468
      

  5.   

    我已经解决了
    谢谢 TheAres(班门斧) 同各位了