文章标签 ‘password’ 的存档

  • php代码实现.Text密码加密方式

    日期:2009.01.07 | 分类:程序开发 | 评论数:1

    今日在转换.Text数据到php平台,需要用到用户密码的问题。
    1234
    .Text里是:0F-03-75-84-C9-9E-7F-D4-F4-F8-C5-95-50-F8-F5-07
    php里md5是:81dc9bdb52d04dc20036dbd8313ed055
    差的还够远的,.Text里面在md5前还Unicode一把。
    注:我不得不承认M$在多字节编码中做的是在是好,从98以后开始,统一平台,应用程序都不存在编码问题,MSSQL用的一点问题都没,反看Php、MySQL编码问题都头大了。

    网上都没有现成的代码,还是在php手册里看到一句话:

    If you are trying to emulate the UnicodeEncoding.Unicode.GetBytes() function in .NET, the encoding you want to use is: UCS-2LE

    URL:http://cn2.php.net/manual/en/ref.mbstring.php#70294
    莫大的启发啊。php要支持:Multibyte String,mbstring哦。
    .Text密码加密方式:

    password = password.ToLower();
    Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
    Byte[] hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

    php代码实现:

    strtoupper(substr(chunk_split(md5(mb_convert_encoding(strtolower($password), 'UCS-2LE')), 2, '-'), 0, -1));

最热文章

最近评论

  • best ultimate demon bonus: Hi! I thought this page is of ...
  • zgdesigner: 我也碰到这个问题,百思不得其解,看了你的文章茅塞大开,很感谢...
  • john: i can not install scws on winx...
  • Lendy: Sorry,现在才看到,不过发现你能分词了。...
  • BlueF: 我成功安装了这一系列的东西,但是还是无法正确的分词,大部分都...
  • Lendy: 3月就出vs2008了,直接用2008好了。...
  • Yu: 能给我刻张盘吗,谢谢,...