Jump to content

Recommended Posts

If it is the Case standard, why does it still continue to encrypt?
thanks

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
$sString1 = "ABC"
$sString2 = "123"
$Form1 = GUICreate("Form1", 528, 145)
$Input1 = GUICtrlCreateInput("", 8, 64, 504, 21, $es_readonly)
$Input2 = GUICtrlCreateInput("", 8, 104, 504, 21, $es_readonly)
GUICtrlSetData($Input1, $sString1)
GUICtrlSetData($Input2, $sString2)
$Combo1 = GUICtrlCreateCombo("standard", 8, 16, 504, 25)
GUICtrlSetData($Combo1, 'MD2|MD4|MD5|')
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "MD2"
                    $g_iAlgorithm = $CALG_MD2

                Case "MD4"
                    $g_iAlgorithm = $CALG_MD4

                Case "MD5"
                    $g_iAlgorithm = $CALG_MD5

                Case "standard"
                    _Reset()
            EndSwitch
            _Crypt_Startup()
            $Input1Read = GUICtrlRead($Input1)
            $Input2Read = GUICtrlRead($Input2)
            GUICtrlSetData($Input1, StringTrimLeft(_Crypt_HashData($Input1Read, $g_iAlgorithm), 2))
            GUICtrlSetData($Input2, StringTrimLeft(_Crypt_HashData($Input2Read, $g_iAlgorithm), 2))
            _Crypt_Shutdown()
    EndSwitch
WEnd
Func _Reset()
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input1, $sString1)
    GUICtrlSetData($Input2, $sString2)
EndFunc   ;==>_Reset

 

Link to post
Share on other sites

You immediately encrypt after calling _Reset() (after your first EndSwitch). You could make crypt a function and call it in each case except for "standard".

 

Like this

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "MD2"
                    $g_iAlgorithm = $CALG_MD2
                    _Encrypt()
                Case "MD4"
                    $g_iAlgorithm = $CALG_MD4
                    _Encrypt()
                Case "MD5"
                    $g_iAlgorithm = $CALG_MD5
                    _Encrypt()
                Case "standard"
                    _Reset()
            EndSwitch
    EndSwitch
WEnd

Func _Encrypt()
    _Crypt_Startup()
    $Input1Read = GUICtrlRead($Input1)
    $Input2Read = GUICtrlRead($Input2)
    GUICtrlSetData($Input1, StringTrimLeft(_Crypt_HashData($Input1Read, $g_iAlgorithm), 2))
    GUICtrlSetData($Input2, StringTrimLeft(_Crypt_HashData($Input2Read, $g_iAlgorithm), 2))
    _Crypt_Shutdown()
EndFunc   ;==>_encrypt

 

Edited by paw
Link to post
Share on other sites

Thanks I understood for the answer.
There is one more problem!
For example, choosing md2 is ok, when choosing md5 it crypt the md2 code, so I don't want it to crypt one another.
I always want to crypt data from the $sString1 and $sString1 variable I set.

Edit: As a workaround, after adding _Reset()  again after Case $Combo1

Case $Combo1
            _Reset()
            Switch GUICtrlRead($Combo1)
                Case "MD2"
                    $g_iAlgorithm = $CALG_MD2
                    _Encrypt()
                Case "MD4"
                    $g_iAlgorithm = $CALG_MD4
                    _Encrypt()
                Case "MD5"
                    $g_iAlgorithm = $CALG_MD5
                    _Encrypt()
                Case "standard"
                    _Reset()
            EndSwitch

 

Edited by Zero0
Editing return
Link to post
Share on other sites

The reason is, you are capturing the contents of the input fields, then hashing that.  So it just keeps rehashing the contents over and over.  If you only want it hash ABC and 123 every time, then hash $sString1 and $sString2 respectively instead of reading the controls contents.

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

    No registered users viewing this page.

×
×
  • Create New...