Código: Seleccionar todo
import Data.Char
l213 xs k | k > 744 = error "La key a de ser menor de 745" | otherwise = ["LUCIFER213" !! (digitToInt x) |x <- concat[ if length y == 4 then tail y else y | y <- ['0':show (ord f + k)| f <- xs]]]
desL213 [] _ = [];desL213 (a:b:c:xs) k | k > 744 = error "La key a de ser menor de 745" | otherwise = chr((read [w | x <- a:b:c:"",s <- [i |(s,i) <- zip "LUCIFER213" [0..9],x==s],w <- show s]::Int)-k):desL213 xs k
Muestra:
Código: Seleccionar todo
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( C:\Documents and Settings\Strup\Escritorio
\L213.hs, interpreted )
Ok, modules loaded: Main.
*Main> putStrLn (l213 "Hola puta." 20)
L3CUIUUC1UU2LECUICUI2UIRUU2LRR
*Main> putStrLn (desL213 "L3CUIUUC1UU2LECUICUI2UIRUU2LRR" 20)
Hola puta.
*Main>
Espero os guste el code un saludo