Skip to content

Instantly share code, notes, and snippets.

@sebolio
Last active May 24, 2019 05:31
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 sebolio/8aa640f15f657e85a6aacd1cfe7a9e4f to your computer and use it in GitHub Desktop.
Save sebolio/8aa640f15f657e85a6aacd1cfe7a9e4f to your computer and use it in GitHub Desktop.
rc4
function rc4(r,f){var n=[],o=0,a,t="";for(var v=0;v<256;v++){n[v]=v}for(v=0;v<256;v++){o=(o+n[v]+r.charCodeAt(v%r.length))%256;a=n[v];n[v]=n[o];n[o]=a}v=0;o=0;for(var c=0;c<f.length;c++){v=(v+1)%256;o=(o+n[v])%256;a=n[v];n[v]=n[o];n[o]=a;t+=String.fromCharCode(f.charCodeAt(c)^n[(n[v]+n[o])%256])}return t}
//uso: rc4(key, string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment