On Mon, 18 Feb 2002 13:51:51 +0100, Eugene Van Der Pijll wrote:
> [EMAIL PROTECTED] schreef op 18 februari 2002:
>> Eugene van der Pijll schreef op 17 februari 2002:
>> > 151:
>> >
>> > sub f{@s[$x,$y]=@s[($y+=$s[$x])%=@s,$x];
>> > $s[$x++]+$s[$y]}@k=pop=~/../g;$y+=hex$k[
>> > $x%@k],f for@s=0..255;$x=1;$y=0;$x%=@s,p
>> > rint$_^chr$s[f()%@s]for<>=~/./g
>>
>> I haven't got a clue about RC4,
>
> Neither have I, and I have no way to test them on long data samples, so
> test it before you use it...
>
>> but inspecting Eugene's
>> masterpiece, can you save a stroke by replacing:
>>
>> rint$_^chr$s[f()%@s]for<>=~/./g
>> with:
>> rint$_^chr$s[255&f]for<>=~/./g
>
> Ah, then I can save another two strokes:
>
> sub f{@s[$x,$y]=@s[($y+=$s[$x])%=@s,$x];
> $s[$x++]+$s[$y]-@s}@k=pop=~/../g;$y+=hex
> $k[$x%@k],f for@s=0..255;$x=1;$y=0;print
> $_^chr$s[f$x%=@s]for<>=~/./g
By the same token, we can shave off another two. This:
$y+=hex$k[$x%@k],f for@s=0..255;
becomes this:
f$y+=hex$k[$x%@k]for@s=0..255;
The full version is at 146:
sub f{@s[$x,$y]=@s[($y+=$s[$x])%=@s,$x];
$s[$x++]+$s[$y]-@s}@k=pop=~/../g;f$y+=he
x$k[$x%@k]for@s=0..255;$x=1;$y=0;print$_
^chr$s[f$x%=@s]for<>=~/./g
-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net