No subject


Thu Jul 5 12:38:43 CEST 2012


you are storing in ksaStep' either.  So to simplify the where clause you
might do this:

ksa' :: Key -> PRGA
ksa' key = (prga,0,0) -- have to zero
   where prga = fst $ foldr (execState . ksaStep' key) (permId,0)
[255,254..0]

ksaStep' :: Key -> Int -> State (Vector Int, Int) ()
ksaStep' key i = do
  (s,j) <- get
  let j' = (j + (s!i) + (key !! (i `mod` length(key)))) `mod` 256
      s' = s // [(i, s!j'), (j',s!i)]
  put $ (s',j')

Which gets rid of some more unnecessary stuff.  A little better I guess.
For the [255,254..0], you could always just replace it with reverse
[0.255].  It isn't a huge deal either way.

And yeah, ny is a bit far away.  But you go have fun.

On Sun, Dec 9, 2012 at 5:39 PM, Joe <xe4mxee at gmail.com> wrote:

> Thanks for your help, not sure why I'd put the key in the State. The
> execState and pointfree-ing made it a lot nicer. You're right on the
> foldr/flip, but I wasn't zeroing the i & j parts of the PRGA, so now I
> have:
>
>
> ksa' :: Key -> PRGA
> ksa' key = (prga,0,0) -- have to zero
>    where (prga,_,_) = foldr (execState . ksaStep' key) (permId,0,0)
> [255,254..0]
>
>
> I need the [255,254..0] since it has to count up, and the "where" to
> set the zeros. I'm not sure if those are worth fixing, or what can be
> done to make either of those any better. Any suggestions would be
> appreciated.
>
> As for running, I was just running "pwCrypt "key" "plaintext"" in ghci
> and checking against the expected keystream/ciphertext.
>
> > And man I just want to say how jealous I am.  I wish I could go to a ny
> haskell group :(.
>
> There's a meeting this week! Edward Kmett and his lens library. Last
> month's had a good crowd, very friendly.
>

--14dae93b6134b132b504d073787c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable



More information about the Beginners mailing list