Skip to content

Instantly share code, notes, and snippets.

@tarcieri
Forked from anonymous/rc4_golf.rb
Created October 22, 2014 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarcieri/46b905502fce8bbd617f to your computer and use it in GitHub Desktop.
Save tarcieri/46b905502fce8bbd617f to your computer and use it in GitHub Desktop.
m=255
r=(0..256)
j=0
Sk=r.to_a.map{|i|j=(j+S[i]+K[i%16])&m}
St=[]
i=j=0
r.each{|i|
i&=m
j=(j+S[i])&m
S[i],S[j]=S[j],S[i]
St<<S[(S[i]+S[j])&m]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment