一个加密解密的问题
using System;using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.IO;
using System.Net;
using System.Security.Cryptography;
/// Encryption 的摘要说明
/// </summary>
public class Encryption
{
public Encryption()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string EncodeBase64(string s)
{
// Base64加密
string strResult = "";
if (s != null && s != "")
{
strResult = Convert.ToBase64String(System.Text.ASCIIEncoding.Default.GetBytes(s));
}
return strResult;
}
public string DecodeBase64(string s)
{
//Base64解密
string strResult = "";
if (s != null && s != "")
{
strResult = System.Text.ASCIIEncoding.Default.GetString(Convert.FromBase64String(s));
}
return strResult;
}
public string MD5(string s)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(s, "MD5");
}
public string GenKeys(int charLen)
{
string outputString = "";
string[] s ={ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
Random ran = new Random();
while (outputString.Length < charLen)
{
outputString += s[ran.Next(s.Length - 1)];
}
return outputString;
}
public string enCode(string s)//加密
{
return clsSecurity.EncryptDES(s,"hfnc").Replace('/','_').Replace('+','$');
}
public string deCode(string s)//解密
{
return clsSecurity.DecryptDES(s.Replace("$", "+").Replace('_', '/'), "hfnc");
}
} --------------------编程问答-------------------- what's your question? --------------------编程问答-------------------- 报错(最后一段那个位置):当前上下文中不存在名称“clsSecurity”,这个怎么改? --------------------编程问答-------------------- 你的当前上下文本来就木有 clsSecurity
从你的代码来看 clsSecurity应该是个 .cs文件 或.dll
在项目中找一下 --------------------编程问答-------------------- 被编译打包了?
--------------------编程问答-------------------- 缺少using
--------------------编程问答-------------------- 没有引入dll,
没有添加using --------------------编程问答--------------------
这个不是System.Web.Security里面的吗? --------------------编程问答--------------------
还要引入哪些啊。为什么另外一个人的他机器上的编译以上这段代码就能通过呢?一个字都没改拷贝来的。 --------------------编程问答-------------------- 顶一下,谁知道还缺少些什么?别人可以编译通过啊。 --------------------编程问答--------------------
把这个clsSecurity 代码贴出来看看 --------------------编程问答-------------------- 刚才编译通过了,我的app_code文件夹里面少clsSecurity.cs文件,我开始以为是system下面的系统函数…… --------------------编程问答-------------------- 是个类呀! --------------------编程问答-------------------- 没有引用
补充:.NET技术 , ASP.NET