Function passwordDeEncrypt(XPassword) 
Dim Stemp, I, L, X, Y 
    L = Len(XPassword) 
    If L <> 16 Then 
        passwordDeEncrypt = XPassword 
    Else 
        passwordDeEncrypt = "" 
        L = Asc(Mid(XPassword, 1, 1)) - 100 
        For I = (16 - L + 1) To 16 
            X = Asc(Mid(XPassword, I, 1)) 
            If X >= 48 And X <= 57 Or X >= 113 And X <= 122 Then 
                Y = 170 - X 
            ElseIf X >= 65 And X <= 80 Or X >= 97 And X <= 112 Then 
                Y = 177 - X 
            Else 
                Y = 171 - X 
            End If 
            passwordDeEncrypt = passwordDeEncrypt & Chr(Y) 
        Next 
    End If 
End Function 谢谢了

解决方案 »

  1.   

    这是vbscript吧,asp.net 下也可以用的呀
      

  2.   

    private  string passwordDeEncrypt(string XPassword)
    {
       string Stemp,L, X, Y ;
       string passwordDe;
       L=XPassword.lenght;
        if(L!=16)
        {
            passwordDe= XPassword ;
        }
        else
       { 
         passwordDe= "";
       }
        L =Math.Asc(Mid(XPassword, 1, 1)) - 100;
        for(int I=(16-L+1);I<16;I++) 
        {
            X = Math.Asc(Mid(XPassword, I, 1)) ;
               If (X >= 48 && X <= 57 || X >= 113 && X <= 122) 
                    Y = 170 - X ;
                ElseIf (X >= 65 && X <= 80 || X >= 97 && X <= 112  )
                    Y = 177 - X ;
                Else 
                    Y = 171 - X ;
                End If 
                passwordDeEncrypt = passwordDeEncrypt || Chr(Y) ;
        }
    }
    你试试
      

  3.   

    private  void passwordDeEncrypt(string XPassword) 

      string Stemp,L, X, Y ; 
      string passwordDe; 
      L=XPassword.lenght; 
        if(L!=16) 
        { 
            passwordDe= XPassword ; 
        } 
        else 
      { 
        passwordDe= ""; 
      } 
        L =Math.Asc(Mid(XPassword, 1, 1)) - 100; 
        for(int I=(16-L+1);I <16;I++) 
        { 
            X = Math.Asc(Mid(XPassword, I, 1)) ; 
              If (X >= 48 && X <= 57 ¦ ¦ X >= 113 && X <= 122) 
                    Y = 170 - X ; 
                ElseIf (X >= 65 && X <= 80 ¦ ¦ X >= 97 && X <= 112  ) 
                    Y = 177 - X ; 
                Else 
                    Y = 171 - X ; 
                End If 
                passwordDeEncrypt = passwordDeEncrypt ¦ ¦ Chr(Y) ; 
        } 

    上面笔误   这个你看看
      

  4.   

                passwordDeEncrypt = passwordDeEncrypt ¦ ¦ Chr(Y) ; 
    这个应该是   passwordDeEncrypt = passwordDeEncrypt + Chr(Y) ; 吗
      

  5.   

    wangjun8868 
     你那方法好像不行
      

  6.   

    你那Asc你求绝对值的吗
    还有MID是什么意思
    在给你写个
      

  7.   

    不知用没有专门的转换工具?http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx
      

  8.   

    private  string passwordDeEncrypt(string XPassword) 

      string passwordDeEncrypt = XPassword;
      int L=XPassword.Lenght;
      int X,Y; 
        if(L!=16) 
        { 
            return XPassword ; 
        } 
        else 
      { 
        L = (int)XPassword[0] - 100; 
        for(int I=(16-L+1);I <16;I++) 
        { 
            X = (int)XPassword[i-1] ; 
              if(X >= 48 && X <= 57 ¦¦ X >= 113 && X <= 122) 
                    Y = 170 - X ; 
                else if(X >= 65 && X <= 80 ¦¦ X >= 97 && X <= 112  ) 
                    Y = 177 - X ; 
                else
                    Y = 171 - X ; 
                passwordDeEncrypt = passwordDeEncrypt + Chr(Y) ; 
        } 
      }

    这个ASP代码很乱啊....可读性也很差.....还不如自己重新写个....命名很不好
      

  9.   

    最后大括号前面加一个
    return passwordDeEncrypt ;
      

  10.   

    解码就叫 Decrypt , 而不要叫 DeEncrypt  ...这样看着好奇怪
      

  11.   

    private  string passwordDeEncrypt(string XPassword) 

      string passwordDeEncrypt = XPassword; 
      int L=XPassword.Lenght; 
      int X,Y; 
        if(L!=16) 
        { 
            return XPassword ; 
        } 
        else 
      { 
        L = (int)XPassword[0] - 100; 
        for(int I=(16-L+1);I <16;I++) 
        { 
            X = (int)XPassword[i-1] ; 
              if(X >= 48 && X <= 57 ¦¦ X >= 113 && X <= 122) 
                    Y = 170 - X ; 
                else if(X >= 65 && X <= 80 ¦¦ X >= 97 && X <= 112  ) 
                    Y = 177 - X ; 
                else 
                    Y = 171 - X ; 
                passwordDeEncrypt = passwordDeEncrypt + Chr(Y) ; 
        } 
      } 

    这里的Chr(Y)不行,说找不到 Chr还有想问下 asp里 L = Asc(Mid(XPassword, 1, 1)) - 100  可以用L = (int)XPassword[0] - 100;
    这个表示吗
      

  12.   

     private  void  passwordDeEncrypt(string XPassword) 
        { 
          int  L, X,Y; 
          string passwordDe; 
          L=XPassword.Length; 
            if(L!=16) 
            { 
                passwordDe= XPassword ; 
            } 
            else 
          { 
            passwordDe= ""; 
          } 
           
            for(int I=(16-L+1);I<16;I++) 
            { 
                X = CSharpASC(Convert.ToChar(XPassword));
                  if  (X >= 48 && X <= 57 || X >= 113 && X <= 122) 
                {
                    Y = 170 - X ; 
                }
                  else  if(X >= 65 && X <= 80 || X >= 97 && X <= 112  ) 
                {
                    Y = 177 - X ;
                } 
                 else 
                {
                  Y = 171 - X ; 
                }
                    
               passwordDe = passwordDe + ((char)Y).ToString();
         } 
        }
        short    CSharpASC(char s)   
        {   
           byte[]   bytes   =   System.Text.Encoding.GetEncoding("gb2312").GetBytes(s.ToString());
           if (bytes.Length == 2)
           {
               return (short)((bytes[0] << 8) + bytes[1]);
           }
           else
           { return bytes[0]; }   
        }
       
      

  13.   

    wangjun8868 谢谢你 你上面写的
    short    CSharpASC(char s)  
        {  
          byte[]  bytes  =  System.Text.Encoding.GetEncoding("gb2312").GetBytes(s.ToString()); 
          if (bytes.Length == 2) 
          { 
              return (short)((bytes[0] < < 8) + bytes[1]); 
          } 
          else 
          { return bytes[0]; } 
    跟syeerzy  L = (int)XPassword[0] - 100; 的功能是一样的

    syeerzy的
    passwordDeEncrypt = passwordDeEncrypt + Chr(Y) ; 
    运行的时候说找不到Chr
      

  14.   

    我用asp运行response.Write(passwordDeEncrypt("mmclhpfDPCDPCyyq"))的时候得到 结果是 manman119用wangjun8868 写的那个代码得到的结果是 mmclhpfDPCDPCyyqmanman11 
      

  15.   

    好了 谢谢大家    private  string passwordDeEncrypt_2(string XPassword) 

      string passwordDeEncrypt = ""; 
      int L=XPassword.Length; 
      int X,Y; 
        if(L!=16) 
        { 
            return XPassword ; 
        } 
        else 
      { 
        L = (int)XPassword[0] - 100; 
        for(int I=(16-L+1);I <17;I++) 
        { 
            X = (int)XPassword[I-1] ;
            if ((X >= 48 && X <= 57) || (X >= 113 && X <= 122))
            {
                Y = 170 - X;
            }
            else if ((X >= 65 && X <= 80) || (X >= 97 && X <= 112))
            {
                Y = 177 - X;
            }
            else
            {
                Y = 171 - X;
            }
            passwordDeEncrypt = passwordDeEncrypt+((char)Y).ToString();
        }  }
      return passwordDeEncrypt;