用XenoCode可以呀.
http://www.google.com/search?hl=zh-CN&q=XenoCode&btnG=Google%E6%90%9C%E7%B4%A2&lr=
http://www.google.com/search?hl=zh-CN&q=XenoCode&btnG=Google%E6%90%9C%E7%B4%A2&lr=
解决方案 »
- C#字符串去重复问题,新手求助
- MSChart 自动填充数据问题
- [跪求]SqlBulkCopy 提高性能
- 一个小问题,求解
- 准备跳槽,散分大行动!有些关于COM/DCOM,COM+,ASP.Net,WS,Remoting的请大家参与讨论!可另开贴加分!
- 一个DataSet填充两个表问题,在线等非常急
- 一个天真的问题,我有这样的一个想法,谁能解析身份证,从中可以得到,省\县\市\出生日期\
- FormatException: 该字符串未被识别为有效的 DateTime 急求大神修改!!!
- 在windows中设了确认对话框confirm,问:如何在C#中得到返回值为true or false
- 怎样生成C#的本地码?
- c#数据库开发用哪本书好? 哪里有下载? 谢谢!
- 在windows中,选中了一个文件,或文件夹,怎样用c#语言获得它的完整路径名
wzpf.com
/// 对称加密
/// </summary>
/// <param name="pToEncrypt"></param>
/// <param name="sKey"></param>
/// <returns></returns>
public static string Encrypt(string pToEncrypt, string sKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider(); byte[] inputByteArray = Encoding.Default.GetBytes(pToEncrypt); des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
MemoryStream ms = new 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);
}
/// 对称解密
/// </summary>
/// <param name="pToDecrypt"></param>
/// <param name="sKey"></param>
/// <returns></returns>
public static string Decrypt(string pToDecrypt, string sKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = new byte[pToDecrypt.Length / 2];
for(int x = 0; x < pToDecrypt.Length / 2; x++)
{
int i = (Convert.ToInt32(pToDecrypt.Substring(x * 2, 2), 16));
inputByteArray[x] = (byte)i;
}
//建立加密对象的密钥和偏移量,此值重要,不能修改
des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(),CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock(); StringBuilder ret = new StringBuilder();
return System.Text.Encoding.Default.GetString(ms.ToArray());
}
大家都有分