日期:2014-05-18 浏览次数:21110 次
//加密 public string TripleDESEcrypt(string plainString,string key) { if(plainString.Equals(string.Empty)) { return plainString; } TripleDESCryptoServiceProvider tdes=new TripleDESCryptoServiceProvider(); PasswordDeriveBytes derive = new PasswordDeriveBytes(key,null); byte[] tdesIV=new byte[8]; byte[] btaKey=derive.CryptDeriveKey("TripleDES","SHA1",0,tdesIV); byte[] btaCode=Encoding.Unicode.GetBytes(plainString); tdes.Mode = CipherMode.ECB; MemoryStream ms=new MemoryStream(); CryptoStream encStream = new CryptoStream(ms,tdes.CreateEncryptor(btaKey,tdesIV),CryptoStreamMode.Write); encStream.Write(btaCode, 0, btaCode.Length); encStream.FlushFinalBlock(); encStream.Close(); return System.Convert.ToBase64String(ms.ToArray()); }
------解决方案--------------------
9楼的,你的解密程序为什么最后要用2个return呢? 请教