Posted September 25, 200816 yr hiThis post is in literate Haskell which means the entire post can be posted into a .lhs file and compiled by GHC.Haskell is a lazy pure functional programming language named after the logician Haskell Curry.http://en.wikipedia.org/wiki/Haskell_(programming_language)http://haskell.orgThe following code generates a random cd key for an old game, Battlefield 1942. I derived the keygen method with OllyDBG on a random keygen I found on astalavista. Thanks NaG-Scrim/Fighting For Fun - it had good music ;D but your generated code is weird, either msvc6 is not so smart at optimization or your src code is strange, never mind I still made sense of the larger picture.> import Char> import Random> import Text.Printf> import System.IO> genkey :: String -> String> genkey inp = inp ++ (fmt first_number) ++ (fmt last_number)> where last_number = compute last_sequences magic_1> last_sequences = (map (\x -> read x :: Int) (sp (inp ++ "00000") 4 5 []))> magic_1 = 0x43> first_number = compute first_sequences magic_2> first_sequences = (map (\x -> read x :: Int) (sp ("00000" ++ inp ++ "00000") 4 7 []))> magic_2 = 0x25> compute :: [Int] -> Int -> Int> compute = mod . sum> fmt v = printf "%02u" (v::Int) :: Stringsplit a string into i parts n times> sp :: String -> Int -> Int -> [String] -> [String]> sp xs 0 n acc = acc> sp xs i n acc = sp (drop n xs) (i-1) n (acc ++ [(take n xs)])> main = do num <- randomRIO ((10^17 :: Int),(10^18-1 :: Int))> putStrLn $ show $ genkey $ show num
November 20, 200816 yr I started in ...BASIC > Pascal > Motorola Assembly > Z80 Assembly > x80/86 Assembly > C (Dos) > Visual Basic > Visual C++ > .Net > Currently learning C# and Revamping my Assembly knowledge under WindowsI kind of got out of Assembly when I got into structured languages. I did used to code some of my sub routines in assemby when I was taking C in college. My professor didn't know what to think but my programs ran faster than anyone else, lol.I really got away from programming for a while and worked on mainly hardware hacking/mod'ing.Never heard of Haskell but it seems interesting. I would like to do some ASIC programming. -D Edited November 20, 200816 yr by ZeR0Patches
January 13, 200916 yr Author I know some people were interested in hearing about Haskell, here is a short podcast from the Parallel Programming section at Intel (15 minutes / 3.4MB) that might spur your interest some more.http://www.blogtalkradio.com/MulticoreSoft...Don-Stewart.mp3
Create an account or sign in to comment