我找了一个只能加密 解密的没有。
var
  str:string;  LenIDNmuber,i:Integer;
  a,sum:LongWord;
begin
  str:='123456789'
  LenIDNmuber:=Length(Str);
  if LenIDNmuber>0 then
  begin
    for i:=1 to LenIDNmuber do
      begin
        a:=ord(Str[i]) shl $19;  
        sum:=sum+a;
      end;
    Edit3.Text:=IntToStr(sum);
  end;这个的解密算法不知道怎么写,别的算法也可以能把数字字母加密 成数字字母  还能解密回来就可以

解决方案 »

  1.   

    function jiemi(s: string): string;
    begin
    for i := 0 to Length(s) do
      Result := Result + chr(strtoint(s[i]) shr $19);
    end;
      

  2.   

    const
      C1=52845; //字符串加密算法的公匙
      C2=22719; //字符串加密算法的公匙
    implementation
    {$R *.dfm}
    function TransChar(AChar: Char): Integer;
    begin
       if AChar in ['0'..'9'] then
          Result := Ord(AChar) - Ord('0')
       else
          Result := 10 + Ord(AChar) - Ord('A');
    end;//字符转化成十六进制
    function StrToHex(AStr: string): string;
    var
       I : Integer;
    //   Tmp: string;
       begin
          Result := '';
          For I := 1 to Length(AStr) do
          begin
             Result := Result + Format('%2x', [Byte(AStr[I])]);
          end;
          I := Pos(' ', Result);
          While I <> 0 do
          begin
             Result[I] := '0';
             I := Pos(' ', Result);
          end;
    end;//十六进制转化成字符
    function HexToStr(AStr: string): string;
    var
       I : Integer;
       CharValue: Word;
       begin
       Result := '';
       for I := 1 to Trunc(Length(Astr)/2) do
       begin
          Result := Result + ' ';
          CharValue := TransChar(AStr[2*I-1])*16 + TransChar(AStr[2*I]);
          Result[I] := Char(CharValue);
       end;
    end;
    //字符串加密函数
    function Encrypt(const S: String; Key: Word): String;
    var
       I : Integer;
    begin
          Result := S;
          for I := 1 to Length(S) do
          begin
             Result[I] := char(byte(S[I]) xor (Key shr 8));
             Key := (byte(Result[I]) + Key) * C1 + C2;
             if Result[I] = Chr(0) then
                Result[I] := S[I];
          end;
          Result := StrToHex(Result);
    end;//字符串解密函数
    function Decrypt(const S: String; Key: Word): String;
    var
       I: Integer;
       S1: string;
    begin
       S1 := HexToStr(S);
       Result := S1;
       for I := 1 to Length(S1) do
       begin
          if char(byte(S1[I]) xor (Key shr 8)) = Chr(0) then
             begin
                Result[I] := S1[I];
                Key := (byte(Chr(0)) + Key) * C1 + C2; //保证Key的正确性  
             end
          else
             begin
                Result[I] := char(byte(S1[I]) xor (Key shr 8));
                Key := (byte(S1[I]) + Key) * C1 + C2;
             end;
       end;
    end;
    这个我试过,绝对可以。