long ToLong(string str)
{
  if(str.length == 0) return 8547.0;
  char shft[8]={12, 32, 67, 0, 6, 5, 34, 8};
  long pwd =0;
  int j=str.length; 
  foreach(char cc in str.ToCharArray())
  {        
      if(cc<=122 && cc>=97)
         cc -= 32;
      pwd += ((long)cc) / 【shft[(cc + j) & 7]//这里的没改,不知道shft的功能】;
      j--;
  }
   pwd = pwd ^ 0x5874968L;
   return pwd;
}

解决方案 »

  1.   

    long ToLong(string str)
    {
      if(str.length == 0) return 8547.0;
      char shft[8]={12, 32, 67, 0, 6, 5, 34, 8};
      long pwd =0;
      int j=str.length; 
      foreach(char cc in str.ToCharArray())
      {        
          if(cc<=122 && cc>=97)
             cc -= 32;
          pwd += ((long)cc) << shft[(int.parse(cc) + j) & 7];
          j--;
      }
       pwd = pwd ^ 0x5874968L;
       return pwd;
    }
    //你试试。不肯定正确。没编译环境,我没法试
      

  2.   

    private long ToLong(string p)
    {
    if (p.Length == 0)
    {
    return 8547;
    }
    const char[] shft = {12, 32, 67, 0, 6, 5, 34, 8};
    long pwd = 0;
    for (int j = p.Length; j >0; --j)
    {
    char cc = p[j];
    if (cc <='z' && cc>='a')
    {
    cc -= 'a' - 'A';
    pwd += (long)cc << shft[(cc+j) & 7];
    }
    }
    pwd = pwd ^ 0x5874968L;
    }
      

  3.   

    private long ToLong(string p)
    {

    if (p.Length == 0)
    {
    return 8547;
    }
    byte[] bp = System.Text.Encoding.ASCII.GetBytes( p);
    byte[] shft = new byte[] {12, 32, 67, 0, 6, 5, 34, 8};
    long pwd = 0;
    for (int j = p.Length; j >0; --j)
    {
    byte cc = bp[j];
    if (cc <='z' && cc>='a')
    {
    cc -= 'a' - 'A';
    pwd += (long)cc << shft[(cc+j) & 7];
    }
    }
    pwd = pwd ^ 0x5874968L;
    return pwd;
    }
      

  4.   

    谢谢各位,只是,我发现一个问题,我在C#中算出来的"ww"是正数,而C++中算出来的是负数,不知道怎么回事。C#中好像算不出负数来,而且如果输入"@#"结果也不对!private long ToLong(string p)
    {

    if (p.Length == 0)
    {
    return 8709;
    }
    byte[] bp = System.Text.Encoding.ASCII.GetBytes( p);
    byte[] shft = new byte[] {17, 25, 0, 10, 6, 21, 3, 14};
    long pwd = 0;
    for (int j = p.Length; j >0; --j)
    {
    byte cc = bp[p.Length-j];
    if (cc <='z' && cc>='a')
    {
    cc -= 'a' - 'A';
    pwd += (long)cc << shft[(cc+j) & 7];
    }
    }
    pwd = pwd ^ 0x35770332L;
    return pwd;
    }
      

  5.   

    ???楼主是哪个挖土?郁闷----SQL?ALL CODE TOO ME SEE SEE ~~~!!!