Dieses muss ich nach C# übersetzen, das geht so weit ganz wunderbar (hoffe ich zumindest)
jetzt habe ich aber festgestellt, dass die Funktion:
Code: Alles auswählen
def rc4crypt(data, key):
x = 0
box = range(256)
for i in range(256):
x = (x + box[i] + ord(key[i % len(key)])) % 256
box[i], box[x] = box[x], box[i]
x = 0
y = 0
out = []
for char in data:
x = (x + 1) % 256
y = (y + box[x]) % 256
box[x], box[y] = box[y], box[x]
out.append(chr(ord(char) ^ box[(box[x] + box[y]) % 256]))
return ''.join(out)
Code: Alles auswählen
static byte[] rc4crypt(byte[] data,byte[] key)
{
byte[] ret = new byte[data.Length];
byte[] box = new byte[256];
int x = 0, y = 0, i = 0;
byte temp = 0;
for (x = 0; x < 256; x++)
{
box[x] = (byte)x;
}
for (i = 0; i < 256; i++)
{
x = (x + box[i] + key[i % key.Length]) % 256;
temp = box[i];
box[i] = box[x];
box[x] = temp;
}
x = y = 0;
for(i=0;i<data.Length;i++)
{
x = (x + 1) % 256;
y = (y + box[x]) % 256;
temp = box[y];
box[y] = box[x];
box[x] = temp;
ret[i] = (byte)(data[i] ^ box[(box[x] + box[y]) % 256]);
}
return ret;
}
box[y] = box[x];
box[x] = temp;
entspricht
Weiss das jemand?
ich kann gerne auch das komplette skript hochladen