Jump to content

Recommended Posts

Posted (edited)

why does msgboxes show different result in this code?

#include <Crypt.au3>
; Script Start - Add your code below here
_Crypt_Startup()
$yo = _Crypt_HashData(500, $CALG_MD5)
MsgBox(0,"",$yo)
$500 ='500'
$yo = _Crypt_HashData($500, $CALG_MD5)
MsgBox(0,"",$yo)

$yo = _Crypt_HashData('500', $CALG_MD5)
MsgBox(0,"",$yo) ; Correct Result
_Crypt_Shutdown()

$500 = 500
$500two = "'" & $500 & "'"
$yo = _Crypt_HashData($5002, $CALG_MD5)
MsgBox(0, "", $yo)
Edited by ActualAkshay
  • Moderators
Posted (edited)

ActualAkshay,

You get a different result from the first encryption because you are encrypting a number - the second and third results are identical (as I expected) because you are encrypting the same string in each case. ;)

All clear? :huh:

M23

Edit: And the fourth is different again because you are encrypting a different string (with surrounding quotes). ;)

Edited by Melba23

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:

  Reveal hidden contents

 

Posted

  On 2/15/2013 at 1:34 PM, 'Melba23 said:

ActualAkshay,

You get a different result from the first encryption because you are encrypting a number - the second and third results are identical (as I expected) because you are encrypting the same string in each case. ;)

All clear? :huh:

M23

Oh thank you, feeling better now after knowing this :thumbsup: I was wondering whats happening since an hour lol :sweating:

I have added a 4th case too, please explain that one too :)

Thank you

Regards

  • Moderators
Posted

ActualAkshay,

  Quote

please explain that one too

I did - look at edit in my post above. ;)

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:

  Reveal hidden contents

 

Posted (edited)

If you did want 500 and "500" to return the same encryption string, then look at StringIsDigit, IsNumber and Number.

#include <Constants.au3>
#include <Crypt.au3>

_Crypt_Startup()

Local $sString = '500'
If StringIsDigit($sString) Or IsNumber($sString) Then
    $sString = Number($sString)
EndIf
Local $bHash = _Crypt_HashData($sString, $CALG_MD5)
MsgBox($MB_SYSTEMMODAL, '', $bHash)

Local $iNumber = 500
If StringIsDigit($iNumber) Or IsNumber($iNumber) Then
    $iNumber = Number($iNumber)
EndIf
$bHash = _Crypt_HashData($iNumber, $CALG_MD5)
MsgBox($MB_SYSTEMMODAL, '', $bHash)

_Crypt_Shutdown()
Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

You're very welcome.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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...