Necesito realizar un cifrado RC4 de 128 bits, estoy usando .NET y C#. ¿Hay una función incorporada para hacer esto?RC4 Encriptación de 128 bits en C#
Si no es así, me encontré con esta función que puede hacerlo:
public void RC4(ref Byte[] bytes, Byte[] key)
{
Byte[] s = new Byte[256];
Byte[] k = new Byte[256];
Byte temp;
int i, j;
for (i = 0; i < 256; i++)
{
s[i] = (Byte)i;
k[i] = key[i % key.GetLength(0)];
}
j = 0;
for (i = 0; i < 256; i++)
{
j = (j + s[i] + k[i]) % 256;
temp = s[i];
s[i] = s[j];
s[j] = temp;
}
i = j = 0;
for (int x = 0; x < bytes.GetLength(0); x++)
{
i = (i + 1) % 256;
j = (j + s[i]) % 256;
temp = s[i];
s[i] = s[j];
s[j] = temp;
int t = (s[i] + s[j]) % 256;
bytes[x] ^= s[t];
}
}
Pero no sé si es de 128 bits o no, parece 256, pero realmente no saben la diferencia .
¿Tiene que usar el algoritmo RC4? – Kamyar
@Kamyar - Sí, tiene que ser un cifrado RC4 de 128 bits. – Steven