No subject
Thu Jul 5 12:38:43 CEST 2012
able you are storing in ksaStep' either.=A0 So to simplify the where cl=
ause you might do this:<br><br>ksa' :: Key -> PRGA<br>ksa' key =
=3D (prga,0,0) -- have to zero<br>
=A0=A0 where prga =3D fst $ foldr (execState . ksaStep' key) (permId,0)=
[255,254..0]<br><br>ksaStep' :: Key -> Int -> State (Vector Int,=
Int) ()<br>ksaStep' key i =3D do<br>=A0 (s,j) <- get =A0 <br>=A0 le=
t j' =3D (j + (s!i) + (key !! (i `mod` length(key)))) `mod` 256<br>
=A0=A0=A0=A0=A0 s' =3D s // [(i, s!j'), (j',s!i)]<br>=A0 put $ =
(s',j')<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'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>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Thanks for your help, not sure why I'd p=
ut the key in the State. The<br>
execState and pointfree-ing made it a lot nicer. You're right on the<br=
>
foldr/flip, but I wasn't zeroing the i & j parts of the PRGA, so no=
w I<br>
have:<br>
<br>
<br>
ksa' :: Key -> PRGA<br>
ksa' key =3D (prga,0,0) -- have to zero<br>
=A0 =A0where (prga,_,_) =3D foldr (execState . ksaStep' 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 "where"=
to<br>
set the zeros. I'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 "pwCrypt "key" "plai=
ntext"" in ghci<br>
and checking against the expected keystream/ciphertext.<br>
<div class=3D"im"><br>
> And man I just want to say how jealous I am. =A0I wish I could go to a=
ny haskell group :(.<br>
<br>
</div>There's a meeting this week! Edward Kmett and his lens library. L=
ast<br>
month's had a good crowd, very friendly.<br>
</blockquote></div><br>
--14dae93b6134b132b504d073787c--
More information about the Beginners
mailing list