我写了一个程序,程序启动时首先出现一个登陆界面,登陆界面上有远程SQL的地址,用户名和密码,这里的用户名和密码是写在一个表中的,并不是SQL SERVER的用户,SQL SERVER的访问用户写在程序中,如何对这个SQL SERVER的访问用户和密码进行加密?

解决方案 »

  1.   

    不是吧,baidu  google  到处都是,搜一些嘛!
    懒得search可不是一个好习惯啊!
    const 
          fSeedA = 56789 ;/// 常量 , 
          fSeedB = 54667 ; /// 常量 , 
          fKey=7744 ; // 钥匙 
        
        
      var 
          Form1: TForm1; 
        
      implementation 
        
      {$R *.dfm} 
        
      function Encrypt(const str: string): string; 
      var 
          i, j, iKey: Integer; 
          strGet: string; 
      begin 
          strGet := str; 
          iKey := FKey; 
          Result := strGet; 
          for i := 1 to Length(strGet) do 
          begin 
              Result[i] := Char(byte(strGet[i])xor(iKey shr 8)); 
              iKey := (Byte(Result[I]) + iKey) * FSeedA + FSeedB; 
          end; 
          strGet := Result; 
          Result := ''; 
          for i := 1 to Length(strGet) do 
          begin 
              j := Integer(strGet[i]); 
              Result := Result + Char(65+(j div 26))+ char(65+(j mod 26)); 
          end; 
      end; function Decrypt(const str: string): string; 
      var 
          i, j, iKey: Integer; 
          strGet: string; 
      begin 
          strGet := str; 
          iKey := FKey; 
          Result := ''; 
          for i := 1 to (Length(strGet) div 2) do 
          begin 
              j := (Integer(strGet[2*i-1])-65)*26; 
              j := j + (Integer(strGet[2*i])-65); 
              Result := Result + Char(j); 
          end; 
          strGet := Result; 
          for i := 1 to Length(strGet) do 
          begin 
              Result[i] := Char(byte(strGet[I]) xor (iKey shr 8)); 
              iKey := (Byte(strGet[I]) + iKey) * FSeedA + FSeedB; 
          end; 
      end;