Jump to content

Why does this work?


Recommended Posts

#include<Crypt.au3>
_Crypt_Startup()
$Y = _Crypt_HashData("TrojanDwnloader.32", $CALG_MD5)
_Crypt_Shutdown()
If Not ( $Y <> "0x0E08BBFAB6D554CFBEB79DBCC3A3D740" ) Then MsgBox(0,"Test: 1","Success.")
If Not ( $Y <> "»ú¶ÕTÏŸ·ŒÃ£×@" ) Then MsgBox(0,"Test: 2","Success.")

EDIT: didn't realize that the binary string matches anything...

Never mind that, I used another similar word that came up with a match but now I cant remember it and nothing else

seem's to match the binary string again, other than "TrojanDwnloader.32"

why?

Edited by System238
Link to comment
Share on other sites

  • Moderators

System238,

Why do both strings match up?

Because they are the same? :)

Actually for me the second does not match - here is why:

Test 1:

You are comparing a number to a number - so your convoluted statement works like this:

On my machine
$Y = 0x0E08BBFAB6D554CFBEB79DBCC3A3D740

And so
If Not ( $Y <> "0x0E08BBFAB6D554CFBEB79DBCC3A3D740" ) Then 
If Not ( False ) ; because they match
If True ; So you get a match

Test 2:

You are comparing a anumber to a string - so all will depend on how your number is converted into a string:

On my machine
BinaryToString($Y) = »ú¶ÕTϾ·¼Ã£×@
Which is not         »ú¶ÕTÏŸ·ŒÃ£×@

And so
If Not ( $Y <> "»ú¶ÕTÏŸ·ŒÃ£×@" ) Then 
If Not ( True ) ; because they do not match
If False ; So you do not get a match

I imagine it has to do with the type of coding and the character set you are using - well beyond me I am afraid. I would just stick to the number:number comparison if I were you. :P

And why on earth are you using a Not ( <> ) construction? What is wrong with If ( = )? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

And note the SO BS characters.. (Bad pun?)

Posted Image

Best way IMO:

If Not ( $Y <> Binary("0x0E08BBFAB6D554CFBEB79DBCC3A3D740") ) Then MsgBox(0,"Test: 1","Success.")

I'm guessing that Melbas suggested approach uses string comparison while this compares binary. If there happens conversions of strings to binary first, then this method is still better because the conversion only happens once.

Edited by Manadar
Link to comment
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
 Share

  • Recently Browsing   0 members

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