Jump to content

Recommended Posts

Posted (edited)

Hello,

I'm having trouble whit a scipt what I'm building where this is a snippit from, and hope somebody can help me whit.
The problem lies in when i push the "add" button i want to check if the "user" already exists.
But the search code i build founds 2 hits when i know there is only 1 hit.

does somebody knows what I'm doing wrong?

thanks in advance.

Ps. if somebody knows " if i found the right user how can i rewrite the password for him/her? " an answer to that will be most appriciated :)

#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]

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)

    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))
      Local $iCheck_hit = False
      ConsoleWrite (@CRLF & "##############################################"& @CRLF)
      if ubound($usernames)> 0 then
         for $i = 0 to ubound($usernames)-1
            If  guictrlread($usernamefield) = $usernames[$i] Then
               $iCheck_hit = True
               ConsoleWrite ( "Found! "& @CRLF & $usernames[$i] & " = " & guictrlread($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
;~          Else
;~             ConsoleWrite ( "No! "& @CRLF & $usernames[$i] & " = " & guictrlread($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
            EndIf
         next
      EndIf
      ConsoleWrite ( "##############################################"& @CRLF)
      If $iCheck_hit = False Then
         FileWrite($hFileOpen, $encryptedusername & @CRLF)
         FileWrite($hFileOpen, $encryptedpassword & @CRLF)
      EndIf
    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])
        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",$array_decrypted_usernames[$i])
               If $usernames[$i] = GUICtrlRead($selectuser) Then
                  GUICtrlSetData($usernamefield, $usernames[$i])
                  GUICtrlSetData($passwordfield, $passwords[$i])
                  consolewrite("YES " & $i & " = " &  $usernames[$i] & " | ctr = " & GUICtrlRead($selectuser) & @CRLF)
               Else
;~                         msg( "error",$array_decrypted_usernames[$i])
                  consolewrite("NO " & $i & " = " &  $usernames[$i] & " | ctr = " & GUICtrlRead($selectuser) & @CRLF)
               EndIf
            next
         EndIf
   EndSwitch
WEnd

 

Edited by FMS

as finishing touch god created the dutch

Posted

I can't find a wrong CrLf, this time i see no error:

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
YES 0 = test | ctr = test
NO 1 = test2 | ctr = test
NO 0 = test | ctr = test2
YES 1 = test2 | ctr = test2

what's the issue you have?

Posted

lol, no this time "there is no crlf" :) , thanks for that ;)
But this time is when i try for the second time "add" the same username.
(this i want to check in encrypt function(between the ####### lines)
and when i found a name that is already there i want to change only the old $password whit the new one.(whis is a question on his own:)
but this script found it 2 times :S and don't know where the second time comes from :)

as finishing touch god created the dutch

Posted

thanks @AutoBert,
because this is a snippit i used username & pssword :) just to be a little bit simpler to understand.
these array's arn't realy login checks but in real life a group right set function.
--> iff user X has right Y($password) he might use a function or not.
This way i don't rely on a AD system or what so ever :) and normal users cant dig around in the files the program uses to change anything on there own.

as finishing touch god created the dutch

Posted

I think i got some clue found :)
but can't figure out what exactly or how to overcom it.
I think it's in the function updatecomboandinfo.
When you select a previous filled in username it also add it into the array.
I'm working on it now how to do this :)

 

as finishing touch god created the dutch

Posted (edited)

After som fideling around i get this snippet working :)
Dont know iff I'm on the right track (it's working now but maybe there is still a bug inside:S)
Now that i found the right $password could somebody tell me how to rewrite it?
Did some digging around but din't find anythin usefull.
 

#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>
#Include <GuiComboBoxEx.au3>
$Form1 = GUICreate("Pie", 170, 235, 190, 200)


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)

    if guictrlread($usernamefield) <> "" then
      local $encryptedusername = string(_Crypt_EncryptData(guictrlread($usernamefield), "P14h735536jk3fvvbg", $CALG_AES_128))
      local $encryptedpassword = string(_Crypt_EncryptData(guictrlread($passwordfield ), "P14h735536jk3fvvbg", $CALG_AES_128))
      Local $iCheck_hit = False
      ConsoleWrite (@CRLF & "##############################################"& @CRLF)
      if ubound($usernames)> 0 then
         for $i = 0 to ubound($usernames)-1
            If  guictrlread($usernamefield) = $usernames[$i] Then
               $iCheck_hit = True
               ConsoleWrite ( "Found! "& @CRLF & $usernames[$i] & " = " & guictrlread($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
;~          Else
;~             ConsoleWrite ( "No! "& @CRLF & $usernames[$i] & " = " & guictrlread($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
            EndIf
         next
      EndIf
      ConsoleWrite ( "##############################################"& @CRLF)
      If $iCheck_hit = False Then
         FileWrite($hFileOpen, $encryptedusername & @CRLF)
         FileWrite($hFileOpen, $encryptedpassword & @CRLF)
      EndIf
    EndIf

    FileClose($hFileOpen)
    decrypt()
EndFunc

func decrypt()
   
   _GUICtrlComboBoxEx_ResetContent(GUICtrlGetHandle($selectuser))
   Global $usernames[0]
   Global $passwords[0]

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

   Local $j = 0
    for $i = 1 to _FileCountLines("data.srmt")/2

        local $encryptedusername = FileReadLine($hFileOpen)
        local $encryptedpassword = FileReadLine($hFileOpen)
        
        _ArrayAdd($usernames, binarytostring(_Crypt_DecryptData(binary($encryptedusername), "P14h735536jk3fvvbg", $CALG_AES_128)))
        _ArrayAdd($passwords, binarytostring(_Crypt_DecryptData(binary($encryptedpassword), "P14h735536jk3fvvbg", $CALG_AES_128)))
        ConsoleWrite ($j & " = j ####"& $usernames[$j] & @CRLF)
        GUICtrlSetData($selectuser, $usernames[$j])
        $j = $j + 1
    Next

    FileClose($hFileOpen)
endfunc

decrypt()

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

 

Edited by FMS

as finishing touch god created the dutch

Posted
1 hour ago, FMS said:

Now that i found the right $password could somebody tell me how to rewrite it?

 

i added a func for the rewriting:

#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>
#Include <GuiComboBoxEx.au3>
$Form1 = GUICreate("Pie", 170, 235, 190, 200)


Global $usernames
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)

    if guictrlread($usernamefield) <> "" then
      local $encryptedusername = string(_Crypt_EncryptData(guictrlread($usernamefield), "P14h735536jk3fvvbg", $CALG_AES_128))
      local $encryptedpassword = string(_Crypt_EncryptData(guictrlread($passwordfield ), "P14h735536jk3fvvbg", $CALG_AES_128))
      Local $iCheck_hit = False
      ConsoleWrite (@CRLF & "##############################################"& @CRLF)
      if ubound($usernames)> 0 then
         for $i = 0 to ubound($usernames)-1
            If  guictrlread($usernamefield) = $usernames[$i] Then
               $iCheck_hit = True
               ConsoleWrite ( "Found! "& @CRLF & $usernames[$i] & " = " & guictrlread($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
               ExitLoop ;needed for knowing which pwd maybe changed
               ;otherwise the _ReplacePWDinFile must search agian for it. 
;~          Else
;~             ConsoleWrite ( "No! "& @CRLF & $usernames[$i] & " = " & guictrlread($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
            EndIf
         next
      EndIf
      ConsoleWrite ( "##############################################"& @CRLF)
      If $iCheck_hit = False Then
         FileWrite($hFileOpen, $encryptedusername & @CRLF)
         FileWrite($hFileOpen, $encryptedpassword & @CRLF)
      Else
         _ReplacePWDinFile($encryptedusername,$encryptedpassword,($i+1)*2)
      EndIf
    EndIf

    FileClose($hFileOpen)
    decrypt()
EndFunc

func decrypt()

   _GUICtrlComboBoxEx_ResetContent(GUICtrlGetHandle($selectuser))
   Global $usernames[0]
   Global $passwords[0]

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

   Local $j = 0
    for $i = 1 to _FileCountLines("data.srmt")/2

        local $encryptedusername = FileReadLine($hFileOpen)
        local $encryptedpassword = FileReadLine($hFileOpen)

        _ArrayAdd($usernames, binarytostring(_Crypt_DecryptData(binary($encryptedusername), "P14h735536jk3fvvbg", $CALG_AES_128)))
        _ArrayAdd($passwords, binarytostring(_Crypt_DecryptData(binary($encryptedpassword), "P14h735536jk3fvvbg", $CALG_AES_128)))
        ConsoleWrite ($j & " = j ####"& $usernames[$j] & @CRLF)
        GUICtrlSetData($selectuser, $usernames[$j])
        $j = $j + 1
    Next

    FileClose($hFileOpen)
endfunc

decrypt()

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

Func _ReplacePWDinFile($sUser,$sPWD,$iLine)
    Local $sFilepath="data.srmt"
;   For $i=1 To _FileCountLines($sFilepath) Step 2
;       If $sUser=FileReadLine($sFilepath,$i) Then
;           ConsoleWrite('_ReplacePWDinFile Found: '&$sUser&@TAB&$i&@CRLF)
;           ExitLoop
;       EndIf
;   Next
;   Local $iLine=$i+1
    _FileWriteToLine($sFilepath,$iLine,$sPWD,True)
    ConsoleWrite('_ReplacePWDinFile _FileWriteToLine '&$iLine&': '&@error&' '&@extended&@CRLF)
EndFunc

 

Posted

You noticed that _FileWriteToLine don't work with Filehandle? I suggest further to declare the filepath once as a const and use it in every func needing the filepath: 

#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>
#include <GuiComboBoxEx.au3>
$Form1 = GUICreate("Pie", 170, 235, 190, 200)
ConsoleWrite(@OSVersion & @CRLF)

Global Const $sFilepath = "data.srmt"

Global $usernames
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($sFilepath, $FO_APPEND)

    If GUICtrlRead($usernamefield) <> "" Then
        Local $encryptedusername = String(_Crypt_EncryptData(GUICtrlRead($usernamefield), "P14h735536jk3fvvbg", $CALG_AES_128))
        Local $encryptedpassword = String(_Crypt_EncryptData(GUICtrlRead($passwordfield), "P14h735536jk3fvvbg", $CALG_AES_128))
        Local $iCheck_hit = False
        ConsoleWrite(@CRLF & "##############################################" & @CRLF)
        If UBound($usernames) > 0 Then
            For $i = 0 To UBound($usernames) - 1
                If GUICtrlRead($usernamefield) = $usernames[$i] Then
                    $iCheck_hit = True
                    ConsoleWrite("Found! " & @CRLF & $usernames[$i] & " = " & GUICtrlRead($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
                    ExitLoop ;needed for knowing which pwd maybe changed
                    ;otherwise the _ReplacePWDinFile must search agian for it.
;~          Else
;~             ConsoleWrite ( "No! "& @CRLF & $usernames[$i] & " = " & guictrlread($usernamefield) & @CRLF & "i = " & $i & @CRLF & @CRLF)
                EndIf
            Next
        EndIf
        ConsoleWrite("##############################################" & @CRLF)
        If $iCheck_hit = False Then
            FileWrite($hFileOpen, $encryptedusername & @CRLF)
            FileWrite($hFileOpen, $encryptedpassword & @CRLF)
        Else
            _ReplacePWDinFile($encryptedusername, $encryptedpassword, ($i + 1) * 2)
        EndIf
    EndIf

    FileClose($hFileOpen)
    decrypt()
EndFunc   ;==>encrypt

Func decrypt()

    _GUICtrlComboBoxEx_ResetContent(GUICtrlGetHandle($selectuser))
    Global $usernames[0]
    Global $passwords[0]

    Local $hFileOpen = FileOpen($sFilepath, $FO_READ)

    Local $j = 0
    For $i = 1 To _FileCountLines($sFilepath) / 2

        Local $encryptedusername = FileReadLine($hFileOpen)
        Local $encryptedpassword = FileReadLine($hFileOpen)

        _ArrayAdd($usernames, BinaryToString(_Crypt_DecryptData(Binary($encryptedusername), "P14h735536jk3fvvbg", $CALG_AES_128)))
        _ArrayAdd($passwords, BinaryToString(_Crypt_DecryptData(Binary($encryptedpassword), "P14h735536jk3fvvbg", $CALG_AES_128)))
        ConsoleWrite($j & " = j ####" & $usernames[$j] & @CRLF)
        GUICtrlSetData($selectuser, $usernames[$j])
        $j = $j + 1
    Next

    FileClose($hFileOpen)
EndFunc   ;==>decrypt

decrypt()

GUISetState(@SW_SHOW)
While True
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $addusername
            encrypt()
            GUICtrlSetData($usernamefield, "")
            GUICtrlSetData($passwordfield, "")
        Case $selectuser
            If UBound($usernames) > 0 Then
                For $i = 0 To UBound($usernames) - 1
                    If $usernames[$i] = GUICtrlRead($selectuser) Then
                        GUICtrlSetData($usernamefield, $usernames[$i])
                        GUICtrlSetData($passwordfield, $passwords[$i])
;~                _GUICtrlComboBox_SetCurSel($usernamefield,$i)
                        ConsoleWrite("YES " & $i & " = " & $usernames[$i] & " | ctr = " & GUICtrlRead($selectuser) & @CRLF)
                    Else
                        ConsoleWrite("NO " & $i & " = " & $usernames[$i] & " | ctr = " & GUICtrlRead($selectuser) & @CRLF)
                    EndIf
                Next
            EndIf
    EndSwitch
WEnd

Func _ReplacePWDinFile($sUser, $sPWD, $iLine)
    ;   For $i=1 To _FileCountLines($sFilepath) Step 2
    ;       If $sUser=FileReadLine($sFilepath,$i) Then
    ;           ConsoleWrite('_ReplacePWDinFile Found: '&$sUser&@TAB&$i&@CRLF)
    ;           ExitLoop
    ;       EndIf
    ;   Next
    ;   Local $iLine=$i+1
    _FileWriteToLine($sFilepath, $iLine, $sPWD, True)
    ConsoleWrite('_ReplacePWDinFile _FileWriteToLine ' & $iLine & ': ' & @error & ' ' & @extended & @CRLF)
EndFunc   ;==>_ReplacePWDinFile

 

Posted (edited)

I noticed it,
I'm comparing it now whit what I just got finished.
It is deleting the file and combo en rebuilding everythin.
(this snippit come's from mine project so the $ aren't the same)
What do you tink of this work flow? (Isn't this way asking more resources instead of your way?)

edit: filewrite whit new $encrypted_username_false
 

func encrypt_rights()
   FileDelete($GL_file_rigths_location);------------------------------------------------------------------------------------backup function?
   Local $hFileOpen = FileOpen($GL_file_rigths_location,  $FO_APPEND)

   if guictrlread($input_username) <> "" then
      local $encrypted_username = string(_Crypt_EncryptData(guictrlread($input_username), $GL_encr_key, $CALG_AES_128))
      local $encrypted_rights = string(_Crypt_EncryptData(guictrlread($combo_right ), $GL_encr_key, $CALG_AES_128))
      Local $iCheck_hit = False
;~    ConsoleWrite (@CRLF & "##############################################"& @CRLF)
      if ubound($array_decrypted_usernames)> 0 then
         for $i = 0 to ubound($array_decrypted_usernames)-1
            If  guictrlread($input_username) = $array_decrypted_usernames[$i] Then
               $iCheck_hit = True
               ConsoleWrite ( "Found! "& @CRLF & $array_decrypted_usernames[$i] & " = " & guictrlread($input_username) & @CRLF & "i = " & $i & @CRLF & @CRLF)
               FileWrite($hFileOpen, $encrypted_username & @CRLF)
               FileWrite($hFileOpen, $encrypted_rights & @CRLF)
            Else
               Local $encrypted_username_false = string(_Crypt_EncryptData($array_decrypted_usernames[$i], $GL_encr_key, $CALG_AES_128))
               Local $encrypted_rights_false = string(_Crypt_EncryptData($array_decrypted_rights[$i], $GL_encr_key, $CALG_AES_128))
               FileWrite($hFileOpen, $encrypted_username_false & @CRLF)
               FileWrite($hFileOpen, $encrypted_rights_false & @CRLF)
            EndIf
         next
      EndIf
;~    ConsoleWrite ( "##############################################"& @CRLF)
      If $iCheck_hit = False Then
         FileWrite($hFileOpen, $encrypted_username & @CRLF)
         FileWrite($hFileOpen, $encrypted_rights & @CRLF)
      EndIf
   EndIf

   FileClose($hFileOpen)
   decrypt_rights()
EndFunc

func decrypt_rights($switch = False)
   Global $array_decrypted_usernames[0]
   Global $array_decrypted_rights[0]

   If $switch = "start" Then
      Local $hFileOpen = FileOpen($GL_file_rigths_location, $FO_READ)
      for $i = 1 to _FileCountLines($GL_file_rigths_location)/2
         local $encrypted_username = FileReadLine($hFileOpen)
         local $encrypted_rights = FileReadLine($hFileOpen)
         _ArrayAdd($array_decrypted_usernames, binarytostring(_Crypt_DecryptData(binary($encrypted_username), $GL_encr_key, $CALG_AES_128)))
         _ArrayAdd($array_decrypted_rights, binarytostring(_Crypt_DecryptData(binary($encrypted_rights), $GL_encr_key, $CALG_AES_128)))
      Next
      FileClose($hFileOpen)
   Else
      _GUICtrlComboBoxEx_ResetContent(GUICtrlGetHandle($combo_usr_select))
      Local $hFileOpen = FileOpen($GL_file_rigths_location, $FO_READ)

      Local $j = 0
      for $i = 1 to _FileCountLines($GL_file_rigths_location)/2
         local $encrypted_username = FileReadLine($hFileOpen)
         local $encrypted_rights = FileReadLine($hFileOpen)
         _ArrayAdd($array_decrypted_usernames, binarytostring(_Crypt_DecryptData(binary($encrypted_username), $GL_encr_key, $CALG_AES_128)))
         _ArrayAdd($array_decrypted_rights, binarytostring(_Crypt_DecryptData(binary($encrypted_rights), $GL_encr_key, $CALG_AES_128)))
         ConsoleWrite ($j & " = j ####"& $array_decrypted_usernames[$j] & @CRLF)
         GUICtrlSetData($combo_usr_select, $array_decrypted_usernames[$j])
         $j = $j + 1
      Next

      FileClose($hFileOpen)
   EndIf
endfunc

 

Edited by FMS

as finishing touch god created the dutch

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
×
×
  • Create New...