Created
October 22, 2014 20:45
-
-
Save pdewacht/e07c4b2d9abc89751644 to your computer and use it in GitHub Desktop.
RC4 in 170 bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rc4(K): | |
B=256;S=range(B);b=c=d=0 | |
for a in S[:]:b=(b+S[a]+K[a%len(K)])%B;S[a],S[b]=S[b],S[a] | |
while 1:c=(c+1)%B;d=(d+S[c])%B;a,b=S[c],S[d]=S[d],S[c];yield S[(a+b)%B] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment