-
-
Save Daeinar/dccc2530f90c5ad6ff63 to your computer and use it in GitHub Desktop.
RC4 stream generation with 135 characters of JavaScript
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
<html> | |
<body> | |
<style> | |
html { font-family: monospace; } | |
</style> | |
<script language="javascript" type="text/javascript"> | |
// RC4 stream generation in 135 chars | |
X=(S,K,k,c,l,f)=>{Y=(r,i)=>{j=0;for(x in r)t=S[i],j+=t+k[i%l],S[j%f]=t+(S[i]=S[j%f],0),r.push(S[(S[i++]+t)%f]),i%=f};Y(S,0);k=K;Y(K,1)} | |
c=4096; | |
l=16; | |
f=256; | |
k=[0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10]; | |
S=[]; | |
K=[]; | |
for(i=0;i<f;i++)S[i]=i; | |
for(i=0;i<c;i++)K[i]=0; | |
X(S,K,k,c,l,f); | |
for(i=0;i<2*c;i++) { | |
if (i%16==0) {document.write('<br>');} | |
document.write( ('00'+K[i].toString(16)).substr(-2)+' '); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses:
https://stackoverflow.com/questions/16201656/how-to-swap-two-variables-in-javascript