乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Delphi加密解密算法

       aaie_ 2016-01-17

      // 加密方法一(通過(guò)密鑰加密解密)
      function EncryptString(Source, Key: string): string;
      function UnEncryptString(Source, Key: string): string;
      //加密方法二(通過(guò)移位加密解密)
      function Encode(Str: string): string;
      function Decode(Str: string): string;
      //加密方法三(異或加密解密)
      function Enc(str: string): string;
      function Dec(str: string): string;

       

      ---------------

      function TFrmRegister.EncryptString(Source, Key: string): string;
      // 對(duì)字符串加密(Source:源 Key:密匙)
      var
      KeyLen: integer;
      KeyPos: integer;
      Offset: integer;
      Dest: string;
      SrcPos: integer;
      SrcAsc: integer;
      Range: integer;
      begin
      KeyLen := Length(Key);
      if KeyLen = 0 then
      Key := 'delphi';
      KeyPos := 0;
      Range := 256;
      randomize;
      Offset := random(Range);
      Dest := format('%1.2x', [Offset]);
      for SrcPos := 1 to Length(Source) do
      begin
      SrcAsc := (Ord(Source[SrcPos]) + Offset) mod 255;
      if KeyPos < KeyLen then
      KeyPos := KeyPos + 1
      else
      KeyPos := 1;
      SrcAsc := SrcAsc xor Ord(Key[KeyPos]);
      Dest := Dest + format('%1.2x', [SrcAsc]);
      Offset := SrcAsc;
      end;
      result := Dest;
      end;

      ---------------

      function TFrmRegister.UnEncryptString(Source, Key: string): string;
      // 對(duì)字符串解密(Src:源 Key:密匙)
      var
      KeyLen: integer;
      KeyPos: integer;
      Offset: integer;
      Dest: string;
      SrcPos: integer;
      SrcAsc: integer;
      TmpSrcAsc: integer;
      begin
      KeyLen := Length(Key);
      if KeyLen = 0 then
      Key := 'delphi';
      KeyPos := 0;
      Offset := strtoint('$' + copy(Source, 1, 2));
      SrcPos := 3;
      repeat
      SrcAsc := strtoint('$' + copy(Source, SrcPos, 2));
      if KeyPos < KeyLen then
      KeyPos := KeyPos + 1
      else
      KeyPos := 1;
      TmpSrcAsc := SrcAsc xor Ord(Key[KeyPos]);
      if TmpSrcAsc <= Offset then
      TmpSrcAsc := 255 + TmpSrcAsc - Offset
      else
      TmpSrcAsc := TmpSrcAsc - Offset;
      Dest := Dest + chr(TmpSrcAsc);
      Offset := SrcAsc;
      SrcPos := SrcPos + 2;
      until SrcPos >= Length(Source);
      result := Dest;
      end;

      ----------------

       

      function TFrmRegister.Decode(Str: string): string;
      var
      TmpChr: AnsiChar;
      i, Len: Integer;
      begin
      Result := Str;
      len := Length(Result);
      TmpChr := result[len];
      for i := Len downto 2 do
      begin
      Result[i] := result[i - 1];
      Result[1] := TmpChr;
      end;
      end;

      function TFrmRegister.Encode(Str: string): string;
      var
      TmpChr: AnsiChar;
      i, Len: Integer;
      begin
      Result := Str;
      len := Length(Result);
      TmpChr := result[1];
      for i := 1 to len - 1 do
      begin
      Result[i] := result[i + 1];
      Result[len] := TmpChr;
      end;
      end;

      ---------

        XorKey: array[0..7] of Byte = ($B2, $09, $AA, $55, $93, $6D, $84, $47);

       

       

      function TFrmRegister.Enc(str: string): string;
      var
      i, j: Integer;
      begin
      Result := '';
      j := 0;
      for i := 1 to Length(str) do
      begin
      Result := Result + IntToHex(Byte(str[i]) xor XorKey[j], 2);
      j := (j + 1) mod 8;
      end;
      end;

       

       

      function TFrmRegister.Dec(str: string): string;
      var
      i, j: Integer;
      begin
      Result := '';
      j := 0;
      for i := 1 to Length(str) div 2 do
      begin
      Result := Result + Char(StrToInt('$' + Copy(str, i * 2 - 1, 2)) xor
      XorKey[j]);
      j := (j + 1) mod 8;
      end;
      end;

       

       

       

       

       

       

       

       

       

       

       

       

       

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多