On Sat, 16 Feb 2002 12:01:21 -0800, Samy Kamkar wrote:
> 
> It's RC4, so far in 182 bytes, accepts a hex key (e.g., a0b1c2) in 
> $ARGV[0] and reads input from <>:
> sub 
> f{@s[$x,$y]=@s[$y,$x]}@k=map{hex}pop=~/../g;$y=($y+$k[$_%@k]+$s[$x=$_])%256,f 
> for@t=@s=0..255;$x=$y=0;$x++,$y+=$s[$x%=256]%256,f,print 
> chr($s[($s[$x]+$s[$y])%256]^ord)for<>=~/./g
> 
> so: perl -e 'print"blah"' | perl -e '...' a0b1c2
> would print out the ASCII value of \xe8\x9c\xc0\xcb
> 
> So, any of you have any ideas of shortening it?

I can't seem to get it below 160 characters.  This is split
arbitrarily at 40 characters; it will not work until joined.

sub f{@s[$x,$y]=@s[($y+=$s[$x])%=@s,$x];
$s[$x]+$s[$y]}@k=pop=~/../g;$y+=hex$k[$x
%@k],f,$x++for@s=0..255;$x=$y=0;$x++,$x%
=@s,print chr($s[f()%@s]^ord)for<>=~/./g

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net

Reply via email to