Jump to content

Recommended Posts

  • 6 months later...
Posted

Hello!

I have tried “MD5FileTest.au3” and I have one question:

When I check MD5 for curl.exe via “MD5FileTest.au3” it gives me the following:

0x04E7677C97AF7E4B8BD1E8D0C9752B1A

When I check via “md5sums.exe” PC-Tools utility it gives me the following:

04E7677C97AF7E4B8BD1E8D0C9752B1A

I am not a big expert .. so my question is:

To present MD5 for curl.exe and others can I just trim 0x and report the rest 04E7677C97AF7E4B8BD1E8D0C9752B1A

Is it a problem?

Thank you!

Posted

This function return the binary data, not a string.

If you convert binary data to hex string by String() or show it using MsgBox(), it started with "0x".

Since "0x" it not a part of MD5, of course you can trim it.

新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

  • 4 years later...
  • 3 months later...
Posted

Just a quick note: it would be more efficient to change the 4 declarations from Local $Opcode to Static $Opcode. That would be a tiny speedup when encode or decode functions are called repeatedly.

Also, don't forget to switch strings to/from UTF8 if you suspect they might contain anything else than your local codepage. The test script once made Unicode-compatible becomes:

; -----------------------------------------------------------------------------
; Base64 Machine Code UDF Example
; Purpose: Provide  Machine Code Version of Base64 Encoder/Decoder In AutoIt
; Author: Ward
; -----------------------------------------------------------------------------

#Include "Base64.au3"

Local $Encode = _Base64Encode(BinaryToString(StringToBinary("The quick brown fox jumps over the lazy ɖɘɠɥლოჸᴟ⁈ℕℤℚℝℂℍℙ∑∀∋≢≰⋟⋞⟪⟫ dog", 4), 1))
MsgBox(0, 'Base64 Encode Data', $Encode)

Local $Decode = _Base64Decode($Encode)
MsgBox(0, 'Base64 Decode Data (Binary Format)', $Decode)

Local $String = BinaryToString($Decode, 4)
MsgBox(0, 'Base64 Decode Data (String Format)', $String, 4)

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

  • 2 years later...
Posted
On 4/16/2017 at 9:56 AM, jchd said:

Also, don't forget to switch strings to/from UTF8 if you suspect they might contain anything else than your local codepage. The test script once made Unicode-compatible becomes:

If it helps somebody, here is a version of the encoding / decoding  autoit code to handle UTF-8 non-latin strings correctly.

The original library is not able to do it:

#include <WinAPI.au3>

Global Const $CP_UTF8 = 65001



;This is the function in Base64.au3
; please note the line converting UTF8 characters to multibyte sequence:

Func _Base64Encode($Data, $LineBreak = 76)
    Local $Opcode = "0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E5BC9C21000"

    Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
    DllStructSetData($CodeBuffer, 1, $Opcode)

; here is the changed functionality to handle UTF8:
;   $Data = Binary($Data)
    $Data = Binary(_WinAPI_WideCharToMultiByte($Data, $CP_UTF8))

    Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
    DllStructSetData($Input, 1, $Data)

    $LineBreak = Floor($LineBreak / 4) * 4
    Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) 
    $OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4

    Local $Ouput = DllStructCreate("char[" & $OputputSize & "]")
    DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
                                                    "ptr", DllStructGetPtr($Input), _
                                                    "int", BinaryLen($Data), _
                                                    "ptr", DllStructGetPtr($Ouput), _
                                                    "uint", $LineBreak)
    Return DllStructGetData($Ouput, 1)
EndFunc


;================================

; and this is the way to decode :

$Decrypt = _Base64Decode($Encrypt)
MsgBox(0, '', $Decrypt)
MsgBox(0, '', _WinAPI_MultiByteToWideChar ( BinaryToString($Decrypt), $CP_UTF8, 0, True ) )

 

Hope this helps you

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...