]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/batcher/rc4.py
2 def __init__(self
, key
, burn
=4096):
8 j
= (j
+ s
[i
] + ord(key
[i
% len(key
)])) % 256
9 s
[j
], s
[i
] = s
[i
], s
[j
]
13 self
.crypt("\x00" * burn
)
15 def crypt(self
, data
):
19 for r
in xrange(len(data
)):
21 j
= (j
+ self
.__s
[i
]) % 256
22 self
.__s
[i
], self
.__s
[j
] = self
.__s
[j
], self
.__s
[i
]
23 ret
.append(chr(ord(data
[r
]) ^ self
.__s
[(self
.__s
[i
] + self
.__s
[j
]) % 256]))