<s> """<STR_LIT>""" <EOL> def arcfour ( key , in_bytes , loops = <NUM_LIT:20> ) : <EOL> kbox = bytearray ( <NUM_LIT> ) <EOL> for i , car in enumerate ( key ) : <EOL> kbox [ i ] = car <EOL> j = len ( key ) <EOL> for i in range ( j , <NUM_LIT> ) : <EOL> kbox [ i ] = kbox [ i - j ] <EOL> sbox = bytearray ( range ( <NUM_LIT> ) ) <EOL> j = <NUM_LIT:0> <EOL> for k in range ( loops ) : <EOL> for i in range ( <NUM_LIT> ) : <EOL> j = ( j + sbox [ i ] + kbox [ i ] ) % <NUM_LIT> <EOL> sbox [ i ] , sbox [ j ] = sbox [ j ] , sbox [ i ] <EOL> i = <NUM_LIT:0> <EOL> j = <NUM_LIT:0> <EOL> out_bytes = bytearray ( ) <EOL> for car in in_bytes : <EOL> i = ( i + <NUM_LIT:1> ) % <NUM_LIT> <EOL> j = ( j + sbox [ i ] ) % <NUM_LIT> <EOL> sbox [ i ] , sbox [ j ] = sbox [ j ] , sbox [ i ] <EOL> t = ( sbox [ i ] + sbox [ j ] ) % <NUM_LIT> <EOL> k = sbox [ t ] <EOL> car = car ^ k <EOL> out_bytes . append ( car ) <EOL> return out_bytes <EOL> def test ( ) : <EOL> from time import time <EOL> clear = bytearray ( b'<STR_LIT>' * <NUM_LIT> ) <EOL> t0 = time ( ) <EOL> cipher = arcfour ( b'<STR_LIT:key>' , clear ) <EOL> print ( '<STR_LIT>' % ( time ( ) - t0 ) ) <EOL> result = arcfour ( b'<STR_LIT:key>' , cipher ) <EOL> assert result == clear , '<STR_LIT>' % ( result , clear ) <EOL> print ( '<STR_LIT>' % ( time ( ) - t0 ) ) <EOL> print ( '<STR_LIT:OK>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test ( ) </s>
