/// 加密数据
/// </summary>
/// <param name="Text"></param>
/// <param name="sKey"></param>
/// <returns></returns>
public static string Encrypt(string Text,string sKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray;
inputByteArray=Encoding.Default.GetBytes(Text);
des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
des.IV = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
System.IO.MemoryStream ms=new System.IO.MemoryStream();
CryptoStream cs=new CryptoStream(ms,des.CreateEncryptor(),CryptoStreamMode.Write);
cs.Write(inputByteArray,0,inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret=new StringBuilder();
foreach( byte b in ms.ToArray())
{
ret.AppendFormat("{0:X2}",b);
}
return ret.ToString();
} 以上代码在winform中,老是报如下错误,
错误 2 命名空间“System.Web”中不存在类型或命名空间名称“Security”。是否缺少程序集引用? E:\易飞外挂\易飞外挂\DBUtility\DESEncrypt.cs 38 53 DBUtility
我想原因可能是System.Web 不能用于winform命名空间,那么在winform应该换成什么样对等的命名空间呢,谢谢高人
/// </summary>
/// <param name="Text"></param>
/// <param name="sKey"></param>
/// <returns></returns>
public static string Encrypt(string Text,string sKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray;
inputByteArray=Encoding.Default.GetBytes(Text);
des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
des.IV = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
System.IO.MemoryStream ms=new System.IO.MemoryStream();
CryptoStream cs=new CryptoStream(ms,des.CreateEncryptor(),CryptoStreamMode.Write);
cs.Write(inputByteArray,0,inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret=new StringBuilder();
foreach( byte b in ms.ToArray())
{
ret.AppendFormat("{0:X2}",b);
}
return ret.ToString();
} 以上代码在winform中,老是报如下错误,
错误 2 命名空间“System.Web”中不存在类型或命名空间名称“Security”。是否缺少程序集引用? E:\易飞外挂\易飞外挂\DBUtility\DESEncrypt.cs 38 53 DBUtility
我想原因可能是System.Web 不能用于winform命名空间,那么在winform应该换成什么样对等的命名空间呢,谢谢高人
解决方案 »
- the given key was not present in the dictionary
- 求帮 C# 模仿windows画板
- 求 HyperLink 绑定数据科学方法
- C#读取oracle中表的number类型
- 在项目中添加另一个项目引用碰到的问题
- 请教高手:如何得到treeview中最后一层选中的行文本?
- 如何防止通过reflector看到程序中的连接字符串??
- 请教高人帮忙!各位大哥帮帮小妹
- 在 ADO.NET 的 OleDb 连接串中如何提供一个属性强制指定 Excel 表格中的所有列的数据类型都为“string”
- 如果只有一个固定IP,我想分别做WEB服务器和邮件服务器,有什么好廉价办法?
- foldingmentstrip 这个控件哪里有
- DataGridview遇到的样式问题
我更改为 .net framework 4.0 ,跳出以下警告,为什么呢警告 1 未能解析引用的程序集“Maticsoft.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL”,因为它对不在当前目标框架“.NETFramework,Version=v4.0,Profile=Client”中的“System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”具有依赖关系。请删除对不在目标框架中的程序集的引用,或考虑重新确定项目的目标。 BLL
DataTable dt = Maticsoft.DBUtility.DbHelperSQL.Query(cpsql).Tables[0];
之前是OK的,更改完后,报如下错误错误 4 命名空间“Maticsoft.DBUtility”中不存在类型或命名空间名称“DbHelperSQL”。是否缺少程序集引用? E:\易飞外挂\易飞外挂\KAIERP\Form1.cs 106 48 HNERP我重新引用了,还是报这样子的错误 ,不明白 了
换别的方法。