[C#]
  public static string CreateServerPasswordFromOriginalPassword(string source)
    {
        byte[] byteA = stringToBytes(source);
        string result = md5(byteA);
                byte[] byteB = new byte[result.Length / 2];
        for (int i = 0; i < result.Length / 2; i++)
        {
            byteB[i] = (byte)Convert.ToInt32(result.Substring(i * 2, 2), 16);
        }        return md5(byteB);    }    public static String md5(byte[] srcBytes)
    {
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] bytes = srcBytes;
        bytes = md5.ComputeHash(bytes);
        md5.Clear();        string ret = "";
        for (int i = 0; i < bytes.Length; i++)
        {
            ret += Convert.ToString(bytes[i], 16).PadLeft(2, '0');
        }        return ret.PadLeft(32, '0');
    }    public static byte[] stringToBytes(string src)
    {
        char[] szChar = src.ToCharArray();
        byte[] szByte = new byte[szChar.Length];
        for (int i = 0; i < szChar.Length; i++)
        {
            szByte[i] = (byte)szChar[i];
        }
        return szByte;
    }

解决方案 »

  1.   

    这用的MD5加密算法。你在网上搜下,应该有php的实现!!
      

  2.   

    我知道 php md5算法就是 MD5($str)
    但是我想要的效果是和NET源码跑出了的值一样。
      

  3.   

    楼主的不是仅仅的MD5,还在此基础上进行了扩展!可惜看不懂C#!
      

  4.   

    想跑出一样的话要保证PHP的MD5和C#的MD5出来的数据是一样,这是前提,你先输入一个MD5(123456)比较一下,如果一样再考虑如何处理。你那个C#的MD5里做了太多的规则,加密,字段截取,转换等,我现在公司没VS无法给你测试
      

  5.   


    PHP的MD5和C#的MD5 肯定一样
      

  6.   

    具体可以看看下面2个内容的文章http://topic.csdn.net/u/20100211/23/206e3896-a274-4d8c-b335-85db1a3692b4.htmlhttp://topic.csdn.net/u/20090226/13/dbd8d533-d084-4600-a882-2afd9ed33055.html