Sign in to follow this  
Followers 0

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

104 posts in this topic

#1 ·  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
1 person likes this

Share this post


Link to post
Share on other sites



#3 ·  Posted

Very nice!

Share this post


Link to post
Share on other sites

#4 ·  Posted

Ward

Very useful! Thank you! :P

Share this post


Link to post
Share on other sites

#6 ·  Posted

Marvelous. *thumbs up*


$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites

#7 ·  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

#8 ·  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

#9 ·  Posted

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


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

#11 ·  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) ?


Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

#12 ·  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

#13 ·  Posted

Share this post


Link to post
Share on other sites

#14 ·  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

#15 ·  Posted

Share this post


Link to post
Share on other sites

#16 ·  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!


[font="Arial Narrow"][sub][font="Courier New"]__Email:[/font] POP3 & SMTP using SSL/TLS (OpenSSL)[font="Courier New"]__Email:[/font] IMAP[font="Courier New"]__Email:[/font] Base64 & SMTP login & Send email direct to MX Server (thanks blindwig)[font="Courier New"]____Win:[/font] Hook Registry Changes[font="Courier New"]____Win:[/font] Read/Write to Alternate Data Streams (ini example)[font="Courier New"]Utility:[/font] GPS Distance Calculations, Vincenty and Haversine formulas; angles and elevation[font="Courier New"]Utility:[/font] Dell Laser Printer (3000-5100) - Print Logger[font="Courier New"]Utility:[/font] Reset Router when Wireless Link Fails[font="Courier New"]Utility:[/font] ImageMagick Batch jpg Processor[font="Courier New"]__Video:[/font] HCenc Batch Frontend[font="Courier New"]__Video:[/font] *DEAD* YouTube Video Encoder (avs/avi to flv)Software On CD's I Like<<back|track3 Ultimate Boot CD for Windows SpinRite Ubuntu ophcrack[/sub][/font]

Share this post


Link to post
Share on other sites

#17 ·  Posted

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


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites

#18 ·  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

#19 ·  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.


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

#20 ·  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


My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

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