//加密
function Tfrmmain.SetEncryption(strValue: String): String;
var
  TempChar: Char;
  PrexValue: String;
  I, strLength: Integer;
begin
  if Trim(strValue) = '' then
  begin
    Result := '';
    Exit;
  end;  strValue := Trim(strValue);
  strLength := Length(strValue);  for I := 1 to strLength DIV 2 do
  begin
    TempChar := strValue[I];
    strValue[I] := strValue[strLength - I + 1];
    strValue[strLength - I + 1] := TempChar;
  end;  PrexValue := IntToStr(Random(100000));
  if Length(PrexValue) > 4 then
     PrexValue := Copy(PrexValue, 1, 4)
  else begin
     PrexValue := StringOfChar('0', 4 - Length(PrexValue)) + PrexValue;
  end;  strValue := PrexValue + strValue;  PrexValue := IntToStr(Random(100000));
  if Length(PrexValue) > 4 then
     PrexValue := Copy(PrexValue, 1, 4)
  else begin
     PrexValue := StringOfChar('0', 4 - Length(PrexValue)) + PrexValue;
  end;  strValue := strValue + prexValue;  for I := 1 to Length(strValue) do
  begin
    TempChar := strValue[I];
    TempChar := Char(Ord(TempChar) + 10);
    strValue[I] := TempChar;
  end;  Result := strValue;
end;//解密
function Tfrmmain.SetDecryption(strValue: String): String;
var
  TempChar: Char;
  I, strLength: Integer;
begin
  if Trim(strValue) = '' then
  begin
    Result := '';
    Exit;
  end;  strValue := Trim(strValue);  for I := 1 to Length(strValue) do
  begin
    TempChar := strValue[I];
    TempChar := Char(Ord(TempChar) - 10);
    strValue[I] := TempChar;
  end;  strValue := Copy(strValue, 5, Length(strValue) - 4);
  strValue := Copy(strValue, 1, Length(strValue) - 4);  strLength := Length(Trim(strValue));  for I := 1 to strLength DIV 2 do
  begin
    TempChar := strValue[I];
    strValue[I] := strValue[strLength - I + 1];
    strValue[strLength - I + 1] := TempChar;
  end;  Result := strValue;
end;
加密效果
加密前:
DATABASE NAME=InfoDB
Server NAME=172.18.1.177
USER NAME=sa
BLOBS TO CACHE=1024
BLOB SIZE=1024
加密后:
::::oxsvxyvksmoz}GOWKX*O]KLK^KN=;=A
B@;:AA;8;8B;8<A;GOWKX*|o€|o]<:<?
<A<Ck}GOWKX*\O]_@A;@
=;B@><:;GORMKM*Y^*]LYVL;@;A
=A<<><:;GOdS]*LYVL><?@
B<:;@?>=<;GN\Ya]]KZ>A>A
PASSWORD=123456

解决方案 »

  1.   

    //加密
    function Tfrmmain.SetEncryption(strValue: String): String;
    var
      TempChar: Char;
      PrexValue: String;
      I, strLength: Integer;
    begin
      if Trim(strValue) = '' then
      begin
        Result := '';
        Exit;
      end;  strValue := Trim(strValue);
      strLength := Length(strValue);  for I := 1 to strLength DIV 2 do
      begin
        TempChar := strValue[I];
        strValue[I] := strValue[strLength - I + 1];
        strValue[strLength - I + 1] := TempChar;
      end;  PrexValue := IntToStr(Random(100000));
      if Length(PrexValue) > 4 then
         PrexValue := Copy(PrexValue, 1, 4)
      else begin
         PrexValue := StringOfChar('0', 4 - Length(PrexValue)) + PrexValue;
      end;  strValue := PrexValue + strValue;  PrexValue := IntToStr(Random(100000));
      if Length(PrexValue) > 4 then
         PrexValue := Copy(PrexValue, 1, 4)
      else begin
         PrexValue := StringOfChar('0', 4 - Length(PrexValue)) + PrexValue;
      end;  strValue := strValue + prexValue;  for I := 1 to Length(strValue) do
      begin
        TempChar := strValue[I];
        TempChar := Char(Ord(TempChar) + 10);
        strValue[I] := TempChar;
      end;  Result := strValue;
    end;//解密
    function Tfrmmain.SetDecryption(strValue: String): String;
    var
      TempChar: Char;
      I, strLength: Integer;
    begin
      if Trim(strValue) = '' then
      begin
        Result := '';
        Exit;
      end;  strValue := Trim(strValue);  for I := 1 to Length(strValue) do
      begin
        TempChar := strValue[I];
        TempChar := Char(Ord(TempChar) - 10);
        strValue[I] := TempChar;
      end;  strValue := Copy(strValue, 5, Length(strValue) - 4);
      strValue := Copy(strValue, 1, Length(strValue) - 4);  strLength := Length(Trim(strValue));  for I := 1 to strLength DIV 2 do
      begin
        TempChar := strValue[I];
        strValue[I] := strValue[strLength - I + 1];
        strValue[strLength - I + 1] := TempChar;
      end;  Result := strValue;
    end;
    加密效果
    加密前:
    DATABASE NAME=InfoDB
    Server NAME=172.18.1.177
    USER NAME=sa
    BLOBS TO CACHE=1024
    BLOB SIZE=1024
    加密后:
    ::::oxsvxyvksmoz}GOWKX*O]KLK^KN=;=A
    B@;:AA;8;8B;8<A;GOWKX*|o€|o]<:<?
    <A<Ck}GOWKX*\O]_@A;@
    =;B@><:;GORMKM*Y^*]LYVL;@;A
    =A<<><:;GOdS]*LYVL><?@
    B<:;@?>=<;GN\Ya]]KZ>A>A
    PASSWORD=123456
      

  2.   

    加密效果
    加密前:
    DATABASE NAME=InfoDB
    Server NAME=172.18.1.177
    USER NAME=sa
    BLOBS TO CACHE=1024
    BLOB SIZE=1024
    PASSWORD=123456
    加密后:
    ::::oxsvxyvksmoz}GOWKX*O]KLK^KN=;=A
    B@;:AA;8;8B;8<A;GOWKX*|o€|o]<:<?
    <A<Ck}GOWKX*\O]_@A;@
    =;B@><:;GORMKM*Y^*]LYVL;@;A
    =A<<><:;GOdS]*LYVL><?@
    B<:;@?>=<;GN\Ya]]KZ>A>A
      

  3.   

    nmurl只对该加密的部分加密。比如空格,回车等。我要把它传到别人的网站上去的,所以乱码没有意义。
      

  4.   

    我这里有DES算法(公开加密算法)加密的源程序及加密原理(用C++builder写的不过你可以将之转换成Delphi),如需要可与我联系。
    Email:[email protected]
      

  5.   

    mkany(马可) 
    请问你是叫马科吗?