<s> """<STR_LIT>""" <EOL> class Arcfour ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , key ) : <EOL> s = range ( <NUM_LIT> ) <EOL> j = <NUM_LIT:0> <EOL> klen = len ( key ) <EOL> for i in xrange ( <NUM_LIT> ) : <EOL> j = ( j + s [ i ] + ord ( key [ i % klen ] ) ) % <NUM_LIT> <EOL> ( s [ i ] , s [ j ] ) = ( s [ j ] , s [ i ] ) <EOL> self . s = s <EOL> ( self . i , self . j ) = ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> return <EOL> def process ( self , data ) : <EOL> ( i , j ) = ( self . i , self . j ) <EOL> s = self . s <EOL> r = '<STR_LIT>' <EOL> for c in data : <EOL> i = ( i + <NUM_LIT:1> ) % <NUM_LIT> <EOL> j = ( j + s [ i ] ) % <NUM_LIT> <EOL> ( s [ i ] , s [ j ] ) = ( s [ j ] , s [ i ] ) <EOL> k = s [ ( s [ i ] + s [ j ] ) % <NUM_LIT> ] <EOL> r += chr ( ord ( c ) ^ k ) <EOL> ( self . i , self . j ) = ( i , j ) <EOL> return r <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import doctest <EOL> doctest . testmod ( ) </s>
