Ver Mensaje Individual
  #5  
Antiguo 29-06-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Aquí tienes el algoritmo traducido del pdf:
Código Delphi [-]
function CrifrarMensajeRC4(Mensaje, Key: String): String;
var
  State: Array[0..255] of Integer;
  X, Y, Index1, Index2: Integer;
  NMen, i,j: Integer;
begin
  Result:= '';
  X:= 0; Y:= 0;
  Index1:= 0; Index2:= 0;
  for i:= 0 to 255 do
    State[i]:= i;
  for i:= 0 to 255 do
  begin
    Index2:= (Byte(key[Index1+1]) + State[i] + Index2 ) mod 256;
    j:= State[Index2];
    State[Index2]:= State[i];
    State[i]:= j;
    Index1:= (Index1 + 1) mod Length(Key);
  end;
  for i:= 0 to Length(Mensaje) - 1 do
  begin
    X:= (X + 1) mod 256;
    Y:= (State[X] + Y) mod 256;
    j:= State[X];
    State[X]:= State[Y];
    State[Y]:= j;
    NMen:= Byte(Mensaje[I+1]) XOR State[(State[X] + State[Y]) mod 256];
    Result:= Result + '-' + IntToHex(NMen,2);
  end;
  Result:= Copy(Result,2,Length(Result));
end;
Responder Con Cita