如题!!!!
解决方案 »
- 怎么从数据库中随机抽取 n条不重复记录
- asp.net新手问题
- 水晶报表怎么在公式里更改文本对象的值?还有怎么动态换行?
- datagrid控件引入数据后怎么控制显示列的大小?
- 关于用asp.net绘制直方图的问题?请帮忙!!
- 怎样让HTML代码共用?在ASP.NET中(100分独给最好解决方法的人)
- 办公系统中怎样显示给用户附件
- 请教 Response.ContentType & Response.Redirect
- 超级郁闷!分说明WEB窗体和WIN窗体!真真的令人难受!System.Web.UI.WebControls无法转变成为system.windows.forms.control!
- 不能动态生成自定义控件?
- 我在做一个系统,用户是属于某个部门的,登陆的时候要选择某个部门才能登陆。。。。。解答问题马上给分
- 请叫一个问题。刚刚做了一个小项目,但是没次第一次浏览页面时都重复显示2次登陆页面。
/// <summary>
/// 得到加密字符串
/// </summary>
/// <param name="strText">要加密字符串</param>
/// <param name="strEncrKey">密钥</param>
/// <returns>加密后字符串</returns>
public string DesEncrypt(string strText, string strEncrKey)//加密函数
{
byte[] byKey=null;
byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey.Substring(0,strEncrKey.Length));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write) ;
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch(System.Exception error)
{
return "error:" +error.Message+"\r";
}
}
/// <summary>
/// 得到解密后字符串
/// </summary>
/// <param name="strText">解密字符串</param>
/// <param name="sDecrKey">密钥</param>
/// <returns>解密后字符串</returns>
public string DesDecrypt(string strText,string sDecrKey)//解密函数
{
byte[] byKey = null;
byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
byte[] inputByteArray = new Byte[strText.Length];
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(sDecrKey.Substring(0,8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = new System.Text.UTF8Encoding();
return encoding.GetString(ms.ToArray());
}
catch(System.Exception error)
{
return "error:"+error.Message+"\r";
} }
#endregion
把这个写的类里调用就 行了
using System.Web.Security;
using System.Security.Cryptography;
可否给给偶一个,谢谢!
[email protected]
发我一个,,谢谢!
请大家相助..
http://community.csdn.net/Expert/topic/4289/4289457.xml?temp=.8950312
[email protected]
谢谢