Cifrado RxBot

Iniciado por Expermicid, Julio 03, 2013, 06:36:21 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Código: delphi
(*
*Cifrado RxBot
*Autor: Metal_Kingdom
*Fecha: 03/07/2013
*Web: UdTools.net
*Uso: RxBot(Cadena, Cifrar [1] / Descifrar [2], Tipo [1] / [2]
*Agradecimientos:
*Jep (Tabla), ..::AX::.., Chequinho, Freddy1990
*)

function IntToHex(Int: Integer): string;
var
  i: Integer;
  Hex: string;
begin;
  Hex := '0123456789ABCDEF';
  i := Abs(Int mod 256);
  while not (i div 16 = 0) do
  begin
    Result:= '';
    Result := Hex[i mod 16 + 1] + Result;
    i := i div 16;
  end;
  if length(Hex[i + 1] + Result) = 1 then
      Result := '0' + Hex[i + 1] + Result
    else
      Result:= Hex[i + 1] + Result;
end;


Function RxBot(Text: string; EncOrDec, mType: ShortInt): string;
var
  sTemp, ArrayTemp, Res, AuxmXOR: string;
  i: integer;
  mXOR, Contador, Simbolo, ArrInt: integer;
const
  Tabla: array [0..255] of byte = (
    $24,$2C,$FA,$24,$7B,$E2,$D7,$51,$9D,$0C,$7E,$AA,$2E,$04,$AF,$C8,$BF,$EF,$06,$A7,
    $AD,$DE,$8C,$47,$CD,$55,$DB,$F1,$F8,$11,$11,$9C,$F6,$DF,$B4,$DC,$F3,$98,$F3,$D6,
    $70,$C9,$CE,$31,$34,$C8,$6A,$86,$FD,$FB,$51,$B0,$07,$B4,$9D,$FD,$BA,$EC,$11,$C3,
    $B0,$F9,$30,$E9,$C3,$73,$C8,$61,$0D,$1F,$EA,$16,$C0,$C8,$D0,$46,$2A,$21,$C7,$A0,
    $FC,$B2,$D0,$84,$E8,$8B,$0A,$3C,$82,$28,$69,$46,$FF,$C6,$8E,$F8,$10,$A3,$8F,$A0,
    $1B,$AB,$82,$2C,$ED,$7F,$31,$2C,$30,$C1,$77,$1E,$10,$3B,$B0,$96,$A9,$36,$D2,$CD,
    $1E,$E8,$96,$99,$3B,$5B,$3C,$F9,$BD,$56,$0A,$ED,$8D,$79,$F2,$05,$11,$64,$34,$E2,
    $AF,$13,$69,$24,$2F,$2E,$78,$C7,$16,$EC,$6F,$1E,$7B,$C7,$A4,$6C,$69,$A1,$A1,$B1,
    $65,$E0,$4C,$DE,$37,$5B,$CE,$85,$ED,$36,$2C,$D1,$62,$36,$BB,$2F,$74,$17,$50,$5E,
    $A9,$E5,$C1,$CB,$94,$CA,$E3,$0F,$8D,$10,$D1,$D7,$4C,$24,$9E,$1E,$83,$C5,$02,$90,
    $BC,$92,$39,$DC,$B4,$87,$6F,$E8,$78,$DB,$76,$F1,$AF,$0B,$D8,$02,$C3,$76,$3A,$A7,
    $62,$43,$CE,$54,$A9,$7F,$C2,$70,$76,$58,$B7,$1E,$51,$0D,$74,$9A,$16,$2C,$40,$06,
    $32,$4D,$96,$DB,$FC,$8F,$C2,$D9,$C9,$C1,$D9,$C2,$B5,$14,$B6,$91);
begin
  if EncOrDec = 1 then
    begin
      for i:= 1 to length(Text) do
        begin
          mXOR:= ord(Text[i]) xor Tabla[i-1];
          str(mXOR, AuxmXOR);
          if mType = 1 then sTemp:= sTemp + AuxmXOR + ',';
          if mType = 2 then sTemp:= sTemp + '\x' + inttohex(mXOR);
        end;
      if mType = 1 then Result:= '{' + sTemp + '0};';
      if mType = 2 then Result:= '"' + sTemp + '\x;"';
    end;

  if EncOrDec = 2 then
    begin
      if mType = 1 then Text:= copy(Text, 2, length(Text) -4);
      if mType = 2 then Text:= copy(Text, 3, length(Text) -6) + '\';
      Contador:= 0;
      Repeat
        if mType = 1 then
          begin
            Simbolo:= pos(',', Text);
            ArrayTemp:= copy(Text, 1, Simbolo -1);
            Val(ArrayTemp, ArrInt, ArrInt);
          end;
        if mType = 2 then
          begin
            Simbolo:= pos('\', Text);
            ArrayTemp:= copy(Text, 2, Simbolo -2);
            Val('$' + ArrayTemp, ArrInt, ArrInt);
          end;
        mXOR:= ArrInt xor Tabla[Contador];
        Res:= Res + chr(mXOR);
        Delete(Text, 1, Simbolo);
        inc(Contador);
      until text = '';

      Result:= Res;
    end;
end;


Saludos