9
« en: Diciembre 05, 2011, 12:29:18 am »
Saludos a todo el foro, primeramente agradecimientos anticipados a todos los que les interese el tema, les comento que estuve buscando el codigo del algoritmo Alleged RC4 y Base 64 realizado en vb6, pero sin resultados, solo encontre uno realizado en C# y bueno yo soy un novato en programación y me preguntaba se alguno de ustedes compañeros pudiese ayudarme convirtiendo o migrando los siguientes codigos hechos en C# a VB6.
ALLEGEDRC4:
public string allegedrc4(string codigo, string llavellegada)
{
int[] State = new int[256 + 1];
string Mensaje = String.Empty;
string llave = String.Empty;
string MsgCif = String.Empty;
int X = 0;
int Y = 0;
int Index1 = 0;
int Index2 = 0;
int NMen = 0;
int i = 0;
short op1 = 0;
int aux = 0;
int op2 = 0;
string nrohex = String.Empty;
X = 0;
Y = 0;
Index1 = 0;
Index2 = 0;
Mensaje = codigo;
llave = llavellegada;
for (i = 0; i <= 255.0; i += 1)
{
State[i] = i;
}
for (i = 0; i <= 255.0; i += 1)
{
op1 = (short)(llave.Substring(Index1 + 1 - 1, 1)[0]);
Index2 = (op1 + State[i] + Index2) % 256;
aux = State[i];
State[i] = State[Index2];
State[Index2] = aux;
Index1 = (Index1 + 1) % llave.Length;
}
for (i = 0; i <= Mensaje.Length - 1; i += 1)
{
X = (X + 1) % 256;
Y = (State[X] + Y) % 256;
aux = State[X];
State[X] = State[Y];
State[Y] = aux;
op1 = (short)(Mensaje.Substring(i + 1 - 1, 1)[0]);
op2 = State[(State[X] + State[Y]) % 256];
NMen = op1 ^ op2;
nrohex = NMen.ToString("X");
if (nrohex.Length == 1)
{
nrohex = "0" + nrohex;
}
MsgCif = MsgCif + nrohex;
}
MsgCif = MsgCif.Substring(MsgCif.Length - (MsgCif.Length));
return MsgCif;
}
BASE 64:
string[] diccionario = new string[64] {
"0", "1", "2", "3", "4", "5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K" ,"L","M","N","O","P","Q","R","S","T","U","V" ,"W","X","Y","Z","a","b","c","d","e","f","g" ,"h","i","j","k","l","m","n","o","p","q","r" ,"s","t","u","v","w","x","y","z","+","/"
};
public string base64(int numero)
{
int cociente = 1; int resto; string palabra = "";
while (cociente > 0)
{
cociente = numero / 64;
resto = numero % 64;
palabra = diccionario[resto] + palabra;
numero = cociente;
}
return (palabra);
}
Otras vez muchas gracias por sus respuestas y/o comentarios.
Oscar J. Crespo
La Paz Bolivia