So the title might be a bit off, I haven't actually figured out the genesis block calculations yet. Just wanted to let you know that I'm not really a great programmer. I started messing with C back in 2011 when I was mining and playing around with cgminer and nonces. I never bothered to crack open a book on C, so most of what I learned has been through trial and error. Honestly, it's kind of like trying to drive a car for a decade without actually knowing what you’re doing.
Don’t expect top-notch code from me. I probably did some things in a very inefficient way or just plain wrong since I'm not sure how to do them better.
You can check out the code here http://pastebin.com/nhuuV7y9, it's written in pure C. No binaries since that would be a bit tricky. The code uses OpenSSL, but since you'll need it anyway for Bitcoin, I don't think it’ll be a big deal.
*Genesis Block finder is included.
Some downsides: the program is set up for just one input and one output, so if you want to create a merkle hash like Freicoin’s with multiple inputs and outputs, this program won’t work for that. It assumes a reward of 50 coins, but that’s easy to tweak in the code. Probably the biggest issue is that I can easily recreate the Bitcoin merkle hash, but when I tried testing it with Litecoin's timestamp message, it didn't work. It’s likely an issue with Unicode. I won't lie, I understand Unicode and ASCII even less than C.
Interesting, the Litecoin genesis block seems to have a Unicode "smart quote" (fancier apostrophe) encoded in UTF-8. With my console configured for UTF-8 encoding, this seems to work to reproduce the LTC genesis tx:
(Notice "Apples" as opposed to "Apple's") This seems to correspond with the genesis tx at this block explorer. Cool, thanks OP!
(Also, this timestsamp may work in bash without terminal settings: "`echo -en NY Times 05/Oct/2011 Steve Jobs, Apple\\\\xE2\\\\x80\\\\x99s Visionary, Dies at 56`")
http://www.evanjones.ca/unicode-in-c.html
But you can also just pass it as binary by converting it to hex reading from a UTF-8 file containing the string...
I have updated the code with block hashing to find a genesis block. If you need to specify custom nonce and unixtime(to re-create a block from some chain), you will have to edit the source.
http://pastebin.com/nhuuV7y9
It looks like you've got a linebreak/space in the first argument. I noticed this in OP's post too, if I double click the first argument it stops highlighting halfway through. If I drag-select the whole thing and paste it somewhere, there's a space. So, make sure you don't have any space between "bc3f" and "4cef".
It's because the nonce and unixtime are different.
For bitcoin, it's unixtime = 1231006505 and nonce = 2083236893
I will have to rework the program a bit and start working with switches for better control and/or parsing the data from a file.