Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2014 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4c3b53936afc1a17c23d to your computer and use it in GitHub Desktop.
Save anonymous/4c3b53936afc1a17c23d to your computer and use it in GitHub Desktop.
m=255
r=(0..256)
j=0
Sk=r.to_a
Sk=Sk.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