RC4 Implentation from pseudocode
Javier Miranda
jemirandav at gmail.com
Fri Jul 13 15:16:50 EDT 2007
Can this "pseudocode" be implemented using Revolution? It´s an encryption
alogorithm called Alleged RC4, there are a number of base convesions and
module operations, also there is array manipulation. Itried and failed
miserably.
FUNCION CifrarMensajeRC4(string Mensaje, string Key ) : string
NUMERO State[256], X = 0, Y = 0, Index1 = 0, Index2 = 0 , NMen, I
string MensajeCifrado = ""
INICIO
PARA I = 0 HASTA 255 HACER
State[I] = I
FIN PARA
PARA I = 0 to 255
Index2 = ( ObtieneASCII(key[Index1]) + State[I] + Index2 ) MODULE 256
IntercambiaValor( State[I], State[Index2] ) // exchange variable values
Index1 = (Index1 + 1) MODULO lenght(Key)
FIN PARA
PARA I = 0 to lenght(Mensaje)-1
X = (X + 1) MODULO 256
Y = (State[X] + Y) MODULE 256
IntercambiaValor( State[X] , State[Y] )
NMen = ObtieneASCII(Mensaje[I]) XOR State[(State[X] + State[Y]) MODULE 256]
MensajeCifrado = MensajeCifrado + "-" +
RellenaCero(ConvierteAHexadecimal(NMen)) // add a 0 if its only one char in
the string
END PARA
RETURN ObtieneSubCadena(MensajeCifrado, 1, LargoCadena(MensajeCifrado) - 1);
end FUNCION
More information about the use-livecode
mailing list