asp.net

位置:IT落伍者 >> asp.net >> 浏览文章

使用ASP.Net加密Cookie[2]


发布日期:2020年01月03日
 
使用ASP.Net加密Cookie[2]
——此文章摘自《ASPNET网络数据库开发实例精解》定价 特价 详细>>

{ //定义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();

//定义加密流

[] [] [] [] []

               

上一篇:ASP.Net网络数据库:修改数据库[4]

下一篇:使用ASP.Net加密Cookie[1]