——此文章摘自《ASP
NET网络数据库开发实例精解》定价
¥
特价
¥
详细>>
{ //定义DES的Provider
DESCryptoServiceProvider desprovider =
new DESCryptoServiceProvider();
//转换解密的字符串为二进制
byte[] buffer = ConvertFromBaseString(valueString);
//定义内存流
MemoryStream memoryStream = new MemoryStream();
//定义加密流
CryptoStream cryptoStream = new CryptoStream(memoryStream
desproviderCreateEncryptor(KeyIV)
CryptoStreamModeRead);
//定义读IO流
StreamReader readerStream = new StreamReader(cryptoStream);
//返回解密后的字符串
return(readerStreamReadToEnd());
}
return(null);
}
public static String EncryptTripleDES(String valueString)
{
if(valueString != )
{ //定义TripleDES的Provider
TripleDESCryptoServiceProvider triprovider =
new TripleDESCryptoServiceProvider();
//定义内存流
MemoryStream memoryStream = new MemoryStream();
//定义加密流
CryptoStream cryptoStream = new CryptoStream(memoryStream
triproviderCreateEncryptor(KeyIV)
CryptoStreamModeWrite);
//定义写IO流
StreamWriter writerStream = new StreamWriter(cryptoStream);
//写入加密后的字符流
writerStreamWrite(valueString);
writerStreamFlush();
cryptoStreamFlushFinalBlock();
memoryStreamFlush();
//返回加密后的字符串
return(ConvertToBaseString(memoryStreamGetBuffer()
(int)memoryStreamLength));
}
return(null);
}
public static String DecryptTripleDES(String valueString)
{
if(valueString != )
{ //定义TripleDES的Provider
TripleDESCryptoServiceProvider triprovider =
new TripleDESCryptoServiceProvider();
//转换解密的字符串为二进制
byte[] buffer = ConvertFromBaseString(valueString);
//定义内存流
MemoryStream memoryStream = new MemoryStream();
//定义加密流
[] [] [] [] []