Last active
May 24, 2019 05:31
-
-
Save sebolio/8aa640f15f657e85a6aacd1cfe7a9e4f to your computer and use it in GitHub Desktop.
rc4
This file contains 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
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