Ver Mensaje Individual
  #1  
Antiguo 28-06-2007
nelostanley nelostanley is offline
Miembro
 
Registrado: oct 2006
Posts: 36
Reputación: 0
nelostanley Va por buen camino
[Ayuda] Algoritmo Allege RC4

Hola Gente,

Quisiera ver si alguien pudiera echarme una mano con este algoritmo.

El documento de referencia esta en este link.

http://www.impuestos.gov.bo/Facturac...AllegedRC4.pdf

Tengo programado los sgte, pero con la pruebas no me da el resultado requerido, quizas algo estoy haciendo mal, de antemano muchas gracias.
Código Delphi [-]
function CifrarMensajeRC4(Mensaje:string;Llave:string):string;
var
    State : array[0..255] of integer;
    x, y, Index1, Index2, NMen, i : integer;
    Cociente, Resto : integer ;
    MensajeCifrado : string ;
begin
    x := 0 ; y := 0 ; Index1 := 0 ; Index2 := 0 ; MensajeCifrado := ''; NMen := 0;
    For i:=0 to 255 do begin
        State[i]:= i;
    end;
    For i:=0 to 255 do begin
        Index2 := (Ord(Llave[Index1]) + State[i] + Index2) MOD 256;
        swapInteger(State[i],State[Index2]);
        Index1 := (Index1 + 1) MOD length(Llave);
    end;
    For i:=0 to length(Llave)-1 do begin
        x := (x + 1) MOD 256;
        y := (State[x] + y) MOD 256 ;
        swapinteger(State[x],State[y]);
        NMen := Ord(Mensaje[i]) XOR State[(State[x] + State[y]) MOD 256] ;
        MensajeCifrado := MensajeCifrado + '-' + RellenaCero(Format('%x',[NMen]));
    end;
        Result := RightStr(MensajeCifrado, (length(MensajeCifrado)-1));
end;

Última edición por marcoszorrilla fecha: 28-06-2007 a las 23:06:59.
Responder Con Cita