# No subject

Thu Jul 5 12:38:43 CEST 2012

```able you are storing in ksaStep&#39; either.=A0 So to simplify the where cl=
ause you might do this:<br><br>ksa&#39; :: Key -&gt; PRGA<br>ksa&#39; key =
=3D (prga,0,0) -- have to zero<br>
=A0=A0 where prga =3D fst \$ foldr (execState . ksaStep&#39; key) (permId,0)=
[255,254..0]<br><br>ksaStep&#39; :: Key -&gt; Int -&gt; State (Vector Int,=
Int) ()<br>ksaStep&#39; key i =3D do<br>=A0 (s,j) &lt;- get =A0 <br>=A0 le=
t j&#39; =3D (j + (s!i) + (key !! (i `mod` length(key)))) `mod` 256<br>
=A0=A0=A0=A0=A0 s&#39; =3D s // [(i, s!j&#39;), (j&#39;,s!i)]<br>=A0 put \$ =
(s&#39;,j&#39;)<br><br>Which gets rid of some more unnecessary stuff.=A0 A =
little better I guess.<br>For the [255,254..0], you could always just repla=
ce it with reverse [0.255].=A0 It isn&#39;t a huge deal either way.<br>
<br>And yeah, ny is a bit far away.=A0 But you go have fun.<br><br><div cla=
ss=3D"gmail_quote">On Sun, Dec 9, 2012 at 5:39 PM, Joe <span dir=3D"ltr">&l=
t;<a href=3D"mailto:xe4mxee at gmail.com" target=3D"_blank">xe4mxee at gmail.com<=
/a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
ut the key in the State. The<br>
execState and pointfree-ing made it a lot nicer. You&#39;re right on the<br=
>
foldr/flip, but I wasn&#39;t zeroing the i &amp; j parts of the PRGA, so no=
w I<br>
have:<br>
<br>
<br>
ksa&#39; :: Key -&gt; PRGA<br>
ksa&#39; key =3D (prga,0,0) -- have to zero<br>
=A0 =A0where (prga,_,_) =3D foldr (execState . ksaStep&#39; key) (permId,0,=
0)<br>
[255,254..0]<br>
<br>
<br>
I need the [255,254..0] since it has to count up, and the &quot;where&quot;=
to<br>
set the zeros. I&#39;m not sure if those are worth fixing, or what can be<b=
r>
done to make either of those any better. Any suggestions would be<br>
appreciated.<br>
<br>
As for running, I was just running &quot;pwCrypt &quot;key&quot; &quot;plai=
ntext&quot;&quot; in ghci<br>
and checking against the expected keystream/ciphertext.<br>
<div class=3D"im"><br>
&gt; And man I just want to say how jealous I am. =A0I wish I could go to a=