
Chris Kuklewicz wrote:
There are several problems with the behavior:
*Main> encrypt "" "XXXXX " *Main> decrypt $ encrypt "" "TANZP XXXXX "
So fixing this case would be the first thing to do, followed by:
*Main> encrypt "hello" "LBVJW XXXXX " *Main> decrypt $ encrypt "hello" "HELLO YFRTQ XXXXX "
Thanks a lot, I think these are all related...some changes in_fives l = trim $ foldr (\x y -> x++" "++y) [] $ unfoldr (splitAtMb 5) (l ++ replicate n 'X') where n = if m5 == 0 then 0 else 5 - m5 m5 = length l `mod` 5 trim :: String -> String trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace process :: (Int -> Int -> Int) -> String -> String process f s = if null str1 then "" else in_fives $ map int2alpha $ zipWith f ints1 ints2 where str1 = trim $ clean s str2 = take (length str1) (keystream newdeck) ints1 = map char2int str1 ints2 = map char2int str2 *Main> decrypt $ encrypt $ decrypt $ encrypt "hello" "HELLO" *Main> decrypt $ encrypt $ decrypt $ encrypt "haskell is miles better" "HASKE LLISM ILESB ETTER" *Main> -- View this message in context: http://www.nabble.com/Solitaire-cipher-tf2500700.html#a6971503 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.