Sign in to follow this  
Followers 0

MD5,SHA1,CRC32,RC4,BASE64,XXTEA machine code version

104 posts in this topic

Posted (edited)

Thanks to Lazycat's great idea. He told us how to use the CallWindowProc API to run machine code.

So I wrote some codes in Sphinx C--, and run them in AutoIt.

Here are MD5, SHA1, CRC32, RC4, and BASE64 algorithm in the attachment. (My CRC32 Code is a bit faster then Lazycat's version)

SHA1_MD5_RC4_BASE64_CRC32.zip

If someone needs other algorithm, please let me know, and I will try my best.

If you are looking for SHA2 or AES, here and here.

2008/08/02 Update Note:

Corrected Block TEA (XXTEA) block cipher is added. Take a look at Wikipedia for detail.

SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip

2008/08/24 Update Note:

Add a parameter $LineBreak to _Base64Encode(). This function will break output line in every 76 characters by default. Thanks to trancexx.

SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip

2008/09/27 Update Note:

Optimize machine code in _Base64Encode() and _Base64Decode().

Fix _Base64Encode() crash problem. Thanks to trancexx.

SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip

Edited by Ward
oapjr likes this

Share this post


Link to post
Share on other sites



Posted

VERY nice.

This will come in very handy to me.

Share this post


Link to post
Share on other sites

Posted

Very nice!

Share this post


Link to post
Share on other sites

Posted

Ward

Very useful! Thank you! :P

Share this post


Link to post
Share on other sites

Posted

Thanks fot this things done, especially for MD5 and BASE64!

Share this post


Link to post
Share on other sites

Posted

Marvelous. *thumbs up*

Share this post


Link to post
Share on other sites

Posted

Great functions, Ward! Thank you very much!

I have one question: The Base64 and the RC4 functions do return the same hashes. I am not an expert and do not have very much knowledge about cryptography, but is that correct? Do Base64 and RC4 base on the same algorithm, or what?

Some more algorithms you (maybe) want to implement:

"MD2", "MD4", "SHA256", "SHA384", "SHA512", "HAVAL128", "HAVAL160", "HAVAL192", "HAVAL224", "HAVAL256", "GHOST", "TIGER128", "TIGER160", "TIGER192", "RIPE-MD128", "RIPE-MD160", "CRC16", "ARC-CRC"

Share this post


Link to post
Share on other sites

Posted

Thanks for this Ward, I have been playing with translating a lot of these functions to regular AutoIt Code, but this solution is faster, and works just as well. I may continue playing with mine just to learn how they all work on the inside.

As a reference, the sourceforge project rehash has all the hashing algorithms you posted, as well as several other good ones, in C++ code, for you to look at. Wasn't sure how the brand of C you used would compare with these, but from what I've seen of the code, it should be very easy to translate it and use it for similar purposes.

Share this post


Link to post
Share on other sites

Posted

oh man was dreaming of it. How did you get the machine code version ?

Share this post


Link to post
Share on other sites

Posted

@Ward

This is REAAAALLY fast !! :P

Very nice.

Thanks

regards

ptrex

Share this post


Link to post
Share on other sites

Posted

That's just awesome. The functions are amazingly small too.

Maybe you could implement more algorithms just for fun (suggested by tehhahn, and SkinnyWhiteGuy) ?

Share this post


Link to post
Share on other sites

Posted

Great functions, Ward! Thank you very much!

I have one question: The Base64 and the RC4 functions do return the same hashes. I am not an expert and do not have very much knowledge about cryptography, but is that correct? Do Base64 and RC4 base on the same algorithm, or what?

What did you mean "return the same hashes"?

Base64 and RC4 have different functions. Base64 is an scheme to encode binary data to ASCII string, however, RC4 is a stream chiper to encrypt your data with a private key.

Share this post


Link to post
Share on other sites

Posted

oh man was dreaming of it. How did you get the machine code version ?

You can find a lot of source code in C about these algorithm, but almost all of them need some modifications to be used. The biggest problem is you can't use the static reference. So some assembly knowledge is very helpful.

Share this post


Link to post
Share on other sites

Posted

nice script and all but how can i make a standalone app to check its own MD5?

Share this post


Link to post
Share on other sites

Posted

nice script and all but how can i make a standalone app to check its own MD5?

You can add the MD5 hash to the end of the exe. When you check the hash, omit the last 16 bytes.

If you worry about it is too easy to be broken, maybe RC4 or XXTEA can be use to encrypt the hash.

Share this post


Link to post
Share on other sites

Posted

Sweet Code!!!

Using the old Base64 code it took 6.344 seconds to encode a 1.3mb file on my computer. Using this it took 0.092 seconds.

:P Well done!

Share this post


Link to post
Share on other sites

Posted

Good job Ward, it' really fast. Thanks 4 sharing :P

Share this post


Link to post
Share on other sites

Posted (edited)

Is it just me, or do some of these functions like sha1 crash on windows server 2003?

EDIT: Yes, I am right, they all crash on windows server 2003. Tested using current release of autoit and tested using newest beta, they all crash.

WARD, or someone else with access to server 2003, id really appreciate it if you could fix this.

Edited by spyrorocks

Share this post


Link to post
Share on other sites

Posted

it takes the machine code from a compiled C-- program. C-- is an old language so maybe the machine code generated can't be interpreted by win2003 and more.

Share this post


Link to post
Share on other sites

Posted

This is uber awesome Ward! :P

You know what would be an awesome addition? Some more encryption algo's :o

AES-256 (rijndael), Blowfish, Triple DES and any others you feel comfortable getting the machine code for :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0