我爱Aspx >> C#.Net >> DotNet中用到的加密算法总结_ASP.NET技巧
1public class CryptUtil
2 {
3 public static string DecryptString(string input)
4 {
5 if (input.Equals(string.Empty))
6 {
7 return input;
8 }
9
10 byte[] byKey = {0x63, 0x68, 0x65, 0x6E, 0x79, 0x75, 0x61, 0x6E};
11 byte[] IV = {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
12 byte[] inputByteArray = new Byte[input.Length];
13 DESCryptoServiceProvider des = new DESCryptoServiceProvider();
14 inputByteArray = Convert.FromBase64String(input);
15 MemoryStream ms = new MemoryStream();
16 CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
17 cs.Write(inputByteArray, 0, inputByteArray.Length);
18 cs.FlushFinalBlock();
19 Encoding encoding = new UTF8Encoding();
20 return encoding.GetString(ms.ToArray());
21 }
22
23 public static string EncryptString(string input)
24 {
25 if (input.Equals(string.Empty))
26 {
27 return input;
28 }
29
30 byte[] byKey = {0x63, 0x68, 0x65, 0x6E, 0x79, 0x75, 0x61, 0x6E};
31 byte[] IV = {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
32 DESCryptoServiceProvider des = new DESCryptoServiceProvider();
33 byte[] inputByteArray = Encoding.UTF8.GetBytes(input);
34 MemoryStream ms = new MemoryStream();
35 CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
Ҷƪл˵?
在Asp.net中为图像加入版权信息_..[04-28]
一个极有可能引发ExecutionEngin..[04-28]
asp.net常用代码_ASP.NET技巧[04-28]
[视频]Visual Studio 2005入门之..[04-28]
[视频]Visual Studio 2005入门之..[04-28]
[视频]Visual Studio 2005入门之..[04-28]
致初学者:PHP比ASP优秀的七个理..[04-28]
PHP:“草根语言”挑战“大腕”J..[04-28]
ASP+全新接触(1)_ASP教程[04-28]
手把手教你使用VB来创建ASP组件(..[04-28]
在Asp.net中为图像加入版权信息_..[04-28]
一个极有可能引发ExecutionEngin..[04-28]
asp.net常用代码_ASP.NET技巧[04-28]
[视频]Visual Studio 2005入门之..[04-28]
[视频]Visual Studio 2005入门之..[04-28]
[视频]Visual Studio 2005入门之..[04-28]
JRun常见问题回答_JSP文摘[04-28]
Java线程的深入探讨_JSP文摘[04-28]
基于JSP的动态网站开发技术_JSP文..[04-28]
JSP 2.1和JSF 1.2规范发布预览版..[04-28]