Samy Kamkar schreef op 16 februari 2002:
> 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, any of you have any ideas of shortening it?
sub
f{@s[$x,$y]=@s[$y%=@s,$x]}@k=map{hex}pop=~/../g;$y+=$k[$_%@k]+$s[$x=$_],f
for@t=@s=0..255;$x=$y=0;$x++,$y+=$s[$x%=@s],f,print
chr($s[($s[$x]+$s[$y])%@s]^ord)for<>=~/./g
(173)
It's not exactly the same; I assume that the expression
$y+=$s[$x%=256]%256 in your version should be ($y+=$s[$x%=256)%=256 ?
Eugene