Jump to content

decrypted array don't match ctrl-read


Recommended Posts

Hello,

I don't know whats wrong whit this picture :)
I've a encrypted and decrypted array called $usernames  (this was whit _Crypt_EncryptData)

if ubound($userNames)> 0 then
  for $i = 0 to ubound($usernames)-1
    If $usernames[$i] = GUICtrlRead($combo_usr_select) Then
      consolewrite("YES " & $i & " = " &  $usernames[$i] & " | ctr = " & GUICtrlRead($combo_usr_select))
    Else
        consolewrite("NO " & $i & " = " &  $usernames[$i] & " | ctr = " & GUICtrlRead($combo_usr_select))
    EndIf
  next
EndIf

When i try to look up the GUICtrlRead($combo_usr_select) in this array he can't find it :S
in every case the consolewrite say's NO instead of YES when $usernames[$i] And GUICtrlRead($combo_usr_select) are equal.

Did i do something wrong ???
please advice and thanks in advanced.

 

as finishing touch god created the dutch

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <Array.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <File.au3>
#Include <Timers.au3>
#include <Crypt.au3>
#include <GuiEdit.au3>

$Form1 = GUICreate("Pie", 170, 235, 190, 200)
local $usernames[0]
local $passwords[0]

$myText="Hello World"

$myText="0x48656C6C6F20576F726C64"

global $selectuser = GUICtrlCreateCombo("", 21, 95, 130, 20)
$addusername = GUICtrlCreateButton("Add", 21, 170, 130, 30)
$usernamefield = GUICtrlCreateInput("", 21, 120, 130, 20)
$passwordfield = GUICtrlCreateInput("", 21, 145, 130, 20, 0x0020)

func encrypt()
    Local $hFileOpen = FileOpen("data.srmt",  $FO_APPEND)
   ;~     Local $hFileOpen = FileOpen("data.txt",  $FO_OVERWRITE + $FO_BINARY)

    if guictrlread($usernamefield) <> "" then
;~   local $encryptedusername = string(guictrlread($usernamefield))
;~   local $encryptedpassword = string(guictrlread($passwordfield))
      local $encryptedusername = string(_Crypt_EncryptData(guictrlread($usernamefield), "P14h735536jk3fvvbg", $CALG_AES_128))
      local $encryptedpassword = string(_Crypt_EncryptData(guictrlread($passwordfield ), "P14h735536jk3fvvbg", $CALG_AES_128))

        FileWrite($hFileOpen, $encryptedusername & @CRLF)
        FileWrite($hFileOpen, $encryptedpassword & @CRLF)
    EndIf

    FileClose($hFileOpen)
EndFunc

func decrypt()
    Local $hFileOpen = FileOpen("data.srmt", $FO_READ)

    consolewrite(_FileCountLines("data.srmt") & " lines in the file" & @CRLF)

    for $i = 1 to _FileCountLines("data.srmt")/2
        local $encryptedusername = FileReadLine($hFileOpen)
        local $encryptedpassword = FileReadLine($hFileOpen)

        consolewrite($encryptedusername  & @CRLF)
        consolewrite($encryptedpassword  & @CRLF)

;~         _ArrayAdd($usernames, FileReadLine($hFileOpen))
;~         _ArrayAdd($passwords, FileReadLine($hFileOpen))

        _ArrayAdd($usernames, binarytostring(_Crypt_DecryptData(binary($encryptedusername), "P14h735536jk3fvvbg", $CALG_AES_128)))
        _ArrayAdd($passwords, binarytostring(_Crypt_DecryptData(binary($encryptedpassword), "P14h735536jk3fvvbg", $CALG_AES_128)))
    Next

    FileClose($hFileOpen)

    consolewrite(ubound($usernames) & " entries in array")
    _arraydisplay($usernames)

    if ubound($userNames)> 0 then
        for $i = 0 to ubound($usernames)-1
            GUICtrlSetData($selectuser, $usernames[$i] & @CRLF)
        next
    EndIf
endfunc

func updatecomboandinfo()
   if not GUICtrlRead($usernamefield) = "" Then
      _ArrayAdd($usernames, GUICtrlRead($usernamefield))
      _ArrayAdd($passwords, GUICtrlRead($passwordfield))

      GUICtrlSetData($selectuser, $usernames[UBound($usernames)-1])

   EndIf
EndFunc

decrypt()

GUISetState(@SW_SHOW)
While True
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit
      Case $addusername
         updatecomboandinfo()
         encrypt()
         GUICtrlSetData($usernamefield, "")
         GUICtrlSetData($passwordfield, "")
      Case $selectuser
         if ubound($userNames)> 0 then
            for $i = 0 to ubound($usernames)-1
;~                      msg( "error",$usernames[$i])
               If $usernames[$i] = GUICtrlRead($selectuser) Then
                  consolewrite("YES " & $i & " = " &  $usernames[$i] & " | ctr = " & GUICtrlRead($selectuser))
               Else
;~                         msg( "error",$usernames[$i])
                  consolewrite("NO " & $i & " = " &  $usernames[$i] & " | ctr = " & GUICtrlRead($selectuser))
               EndIf
            next
         EndIf
      EndSwitch
WEnd

something like this? :)

as finishing touch god created the dutch

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

×
×
  • Create New...