Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell

Name: Anonymous 2006-11-04 7:02

ghc -fglasgow-exts -lcrypt trip.hs
% ./a.out faggot
Ep8pui8Vw2


fap fap fap

module Main where
    import Data.Char
    import Foreign.C.String
    import System.Environment
    import System.IO.Unsafe

    foreign import ccall "crypt.h crypt" c_crypt :: CString -> CString -> IO CString

    crypt :: String -> String -> String
    crypt key salt =
        taketail 10 $
            unsafePerformIO $ peekCString $
            unsafePerformIO $
                withCString key $ \k ->
                withCString salt $ \s ->
                    c_crypt k s
        where
        taketail :: Int -> [a] -> [a]
        taketail i x = (reverse (take i (reverse x)))

    makesalt :: String -> String
    makesalt x =
        map
            fixsalt
            (take 2
                (if (length x) < 2 then ("H.") else (tail x)))
        where
        fixsalt :: Char -> Char
        fixsalt c
            | (inrange '0' '9' c)  = c
            | (inrange ':' '@' c)  = (chr ((ord c) + 7))
            | (inrange 'A' 'Z' c)  = c
            | (inrange '[' '`' c)  = (chr ((ord c) + 6))
            | (inrange 'a' 'z' c)  = c
            | c == '/' || c == '.' = c
            | otherwise            = '.'
            where
            inrange :: Ord a => a -> a -> a -> Bool
            inrange low upp x = x >= low && x <= upp

    tripcode :: String -> String
    tripcode s = crypt s (makesalt s)

    main :: IO ()
    main = do
        args <- getArgs
        putStrLn (tripcode (head args))

Name: Anonymous 2007-01-03 12:19

dup. execute 'dup' (duplicates the value on top of the stack) instead of pushing it onto the stack" pop.
"2" "1" substr. push '2' and then '1' onto the stack and then execute 'substr'" pop.
you should be able to figure out the rest...
as for what language it is, it doesn't have a name yet, but it does have a working compiler (currently unreleased) and about half of the standard library is written.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List