Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

purely functional Keygen written in Haskell - source code

Featured Replies

Posted

hi

This 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.org

The 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

Never Hear Before But Nice Job,What Program You Use To Code ?

  • Author

[quote name='

  • 1 month later...

Does Haskell Support ? Socket,SQL Function 0.o Bytes ? Etc

[quote name='

  • Author

[quote name='

Not Bad,How Long You Took To Learn It ?

  • Author

[quote name='

Well I Am More Into C# = )

  • 3 weeks later...

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 Windows

I 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 by ZeR0Patches

  • 1 month later...
  • 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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.