Jump to content

[solved]Problems with encrypt/Decrypt


Recommended Posts

@BrewManNH i tried your code, i added a new account for example 1 at username and 1 password i checked, it told me it's ok. I exit the aplication and re-enter i press button 1 i added 1 at username and 1 at password and nothing. But i found out if i use _stringencrypt it's does encrypt and decrypt the information even if i exit the aplication.

But now im stuck at searching the ini file i mean the accounts section. It only searches the first account and password the other ones doesn't search

Link to comment
Share on other sites

  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

@SmOke_N I will start to read it at the first hour in the morning i'm going to sleep thank you very much for the help with ini cript.au3.

i hope tommorow i will have some revelation on how can i make the program to search the .ini file for the usernames and passwords and after that to decrypt it (which it's done)

Link to comment
Share on other sites

I tried to replace the code with this one but still no luck, the first account that i create it will decrypts it and compare it but if i make another one it dosen't do anything and only repeats the do until

Case $okLogin 
                            $var = IniReadSection($x&".ini", "accounts")
                                If @error Then 
                                    MsgBox(4096, "", "Error occurred, probably no INI file.")
                                Else
                                    For $i = 1 To $var[0][0]
                                        MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
                                        $test1 = _StringEncrypt(0,$var[$i][0],$criptarekey,1)
                                        $test2 = _StringEncrypt(0,$var[$i][1],$criptarekey,1)
                                        MsgBox(4096, "", "username: " & $test1 & @CRLF & "password: " & $test2)
                                    Next
                                        do 
                                            IniReadSection($x&".ini","accounts")
                                        until $test1 = Guictrlread($Loginput) and $test2 = guictrlread($Loginpass)
                                        Msgbox(0,"Evryika", "Finally it's done")
                                        
                                        
                                EndIf
Link to comment
Share on other sites

You do realize your script will only work with the ini files that are created the same day you run it right? You name your INI files by using the NowDate function. So if you run your script the next day, it will be looking for an ini file with THAT day's date in it. That might be a lot of your problem right there.

EDIT: typos

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Yes i know , the Nowcalc information will be used for logs, and im using now to get used. the name of the ini will be named accounts. And for that i got a solution with the _FileListToArray and make them read. Now im tring to implement the ideea of @ pieeater with inireadsectionnames

Later edit:

I made some modifications to the code exacly how @pieeater told me yesterday night. Now i only have to think at one method to decrypt it so now i think im going to have some stuff to do at work.

If someone could give me some clues here it would be perfect.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <file.au3>
#include <Array.au3>
#include <string.au3>





$NewUser = GUICreate("New username", 209, 188, -1, -1)
$newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21)
$newpassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY)
$Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
$newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17)
$Button1 = GUICtrlCreateButton("Button1", 72, 160, 41, 25)
GUISetState(@SW_SHOW)

global $criptarekey = "parolasuperultrasecreta"
Global $x=StringReplace(_NowDate(), '/', '-')



While 1
    $nMsg = GUIGetMsg()
    $citescini=IniReadSectionNames($x&".ini")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        case $cancelnewuser
            Exitloop
        case $createnewuser
            $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,1)
             If _ArrayFindAll($citescini,$Criptatuser) Then 
                $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,1)
                $a = IniWriteSection($x&".ini",$criptatuser, "password = " & $criptatpass)
                MsgBox( 4096, "User Doesn't Exist", "success")
            Else
                MsgBox( 4096, "Username Found", "Imposter! That username already exists!")
            EndIf


        case $button1
                GUISetState(@SW_DISABLE, $newuser)
                $LoginForm = GUICreate("Enter Username & Password", 298, 170, -1, -1)
                $LogInput = GUICtrlCreateInput("", 8, 40, 241, 21)
                $LogInPass = GUICtrlCreateInput("", 8, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                $OkLogin = GUICtrlCreateButton("&OK", 86, 128, 75, 25, $BS_NOTIFY)
                $ExitLogIn = GUICtrlCreateButton("Exit", 167, 128, 75, 25, $BS_NOTIFY)
                $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
                $LogUsername = GUICtrlCreateLabel("Enter Username", 8, 16, 80, 17)
                GUISetState(@SW_SHOW)


                While 1
                $citescini2 = inireadsectionnames($x".ini")
                $nMsg = GUIGetMsg()
                    Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                            ExitLoop

                        Case $exitlogin
                            exitloop

                        Case $okLogin
                        
                        $decriptuser = _StringEncrypt(0,$citescini2,$criptarekey,1) 
                        #comments-start 
                        make a combination of formula in such a way 
                        1 first time will search the username and decript it 
                        2 second thing you will know what to add to IniReadSection for ex. inireadsection($x".ini","Theusername_is_decrypit) and he will read 
                        3 some minor modifications to the formula down and everything should work.
                        #comments-end
                        $decriptpass = IniReadSection
                            If $test1 = _ArrayFindAll($citescini2,$Criptatuser) and $test2 = _arrayfindall($citescini2,"password = " & $decriptpass) Then 
                                If $test1 = $loginput and $test2 = $loginpass Then
                                    MsgBox( 4096, "Acces Granted", "Everything is working ok")
                                Else
                                    MsgBox( 4096, "Acces Denied", "Wrong Username/password")
                                endif
                            Else
                                MsgBox( 4096, "Dosen't work", "i wonder why")
                            EndIf
                            


                    EndSwitch
                WEnd
            GUISetState(@SW_ENABLE, $newuser)
            GUIDelete($LoginForm)


    EndSwitch
WEnd

LAter LAter edit:

I finally think i foud out how... but now gives me this error i don't know why it dosen't scan it.

Could someone guide me here?

Case $okLogin
                        
                        $decriptuser = _StringEncrypt(0,$citescini2,$criptarekey,1) 
                        #comments-start 
                        make a combination of formula in such a way 
                        1 first time will search the username and decript it 
                        2 second thing you will know what to add to IniReadSection for ex. inireadsection($x".ini","Theusername_is_decrypit) and he will read 
                        3 some minor modifications to the formula down and everything should work.
                        #comments-end
                        If $decriptuser = Guictrlread($Loginput) then
                            $remeber = Guictrlread($Loginput)
                            Msgbox(0,"Test if i remeber", "did i remeber?")
                            msgbox(0,"here works fine", "here works fine")
                            $reads = IniReadSection($x".ini",$remeber)
                                If  _StringEncrypt(0,$reads[1][1],$criptarekey,1) = Guictrlread($Loginpass) Then 
                                    MsgBox( 4096, "Acces Granted", "Everything is working ok")
                                Else
                                    MsgBox( 4096, "Dosen't work", "i wonder why2")
                                EndIf
                        Else 
                                MsgBox( 4096, "Dosen't work", "i wonder why1")
                        Endif
Edited by mircea
Link to comment
Share on other sites

  • Moderators

Using the link I provided yesterday and the udf I created here:

And going off your first post.

Is this what you're looking for?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <file.au3>

; Add Ini Crypt
#include "IniCrypt.au3"

_IniCrypt_Initiate()
_IniCrypt_SetPassword("parolasuperultrasecreta")


Global $gs_username, $gs_password, $gs_ini

Global $NewUser = GUICreate("New username", 209, 188, -1, -1)
Global $newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21)
Global $newupassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
Global $Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY)
Global $Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY)
Global $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
Global $newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        case $cancelnewuser
            Exitloop
        case $createnewuser
            $gs_ini = StringRegExpReplace(_NowDate(), "\W", "") & ".ini"

            $gs_username = GUICtrlRead($newuserinput)
            If String($gs_username) = "" Then
                MsgBox(16 + 262144, "Error", "Username cannot be blank!", 0, $NewUser)
                ContinueLoop
            EndIf


            $gs_password = GUICtrlRead($newupassinput)
            If String($gs_password) = "" Then
                MsgBox(16 + 262144, "Error", "Password cannot be blank!", 0, $NewUser)
                ContinueLoop
            EndIf

            __MyIniAddNewUserAndPass($gs_ini, "accounts", $gs_username, $gs_password)
            Switch @error
                Case -1
                    MsgBox(16 + 262144, "Error", "Unable to read data!", 0, $NewUser)
                    ContinueLoop
                Case 1
                    If MsgBox(32 + 4 + 262144, "Already Exist", _
                        "Username already exists, do you wish to overwrite?", 0, $NewUser) = 6 Then
                        _IniCrypt_Write($gs_ini, "accounts", $gs_username, $gs_password)
                    Else
                        ContinueLoop
                    EndIf
            EndSwitch

            MsgBox(64 + 262144, "Added", "Username: " & $gs_username & @CRLF & _
                "Password: " & $gs_password & @CRLF & @CRLF & _
                "Was added to your data bank.", 0, $NewUser)
            GUICtrlSetData($newuserinput, "")
            GUICtrlSetData($newupassinput, "")
    EndSwitch
WEnd

_IniCrypt_Shutdown()


Func __MyIniAddNewUserAndPass($s_ini, $s_section, $s_user, $s_pass)

    ; Does user already exist
    Local $s_cread = _IniCrypt_Read($s_ini, $s_section, $s_user, "!#NOT-FOUND#!")
    If @error Then Return SetError(-1, 0, 0)

    If $s_cread <> "!#NOT-FOUND#!" Then
        ; user already exists
        ; return error - handle in different function
        Return SetError(1, 0, 0)
    EndIf

    Return _IniCrypt_Write($s_ini, $s_section, $s_user, $s_pass)
EndFunc

** Note **

Since this is an encrypted ini file, I'm using the username as the key ( faster lookup table )

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@smoke_n it's very good and it's exacly what i did before only you did it with less line codes. I tried to understand the code but im stuck at

Func __MyIniAddNewUserAndPass($s_ini, $s_section, $s_user, $s_pass)
why do you have 2 _ _ and not 1 ? and im again stuck with the setError.

$s_cread = _IniCrypt_Read($s_ini, $s_section, $s_user, "!#NOT-FOUND#!")
and the !#not-Found#!" it searches for this value?.

And another question if let's say it writes the username and password and it's encrypted, how would i decrypted it ? do i use the _inicrypt_read? or how would i make to read the section of accounts?.

Sorry but im a bit confused, i hope you can help me.

Edit:

After long time and with your help and ideas it's finally done. My god.... i never thinked it's going to be done.

And i could never done this without the help of this guys

@ SmOke_N with the help of his script which i read it several times ... and in the fact that i didn't understand to much .... i found out a combination of if and else and inireadsectionnames and inireadsection. thank you

@ pieeater with the encrypting example and the inireadsectionnames Thank you very much

@ BrewManNH with the example script which if he didn't show me i would never think of using the stringencrypt which i think it's more better but even so _crypt_encryptdata it's a very handy code.

@ jchd with some advices for encrypting it in a .ini file

Here is the final code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <file.au3>
#include <Array.au3>
#include <string.au3>





$NewUser = GUICreate("New username", 209, 188, -1, -1)
$newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21)
$newpassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY)
$Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
$newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17)
$Button1 = GUICtrlCreateButton("Button1", 72, 160, 41, 25)
GUISetState(@SW_SHOW)

global $criptarekey = "parolasuperultrasecreta"
Global $x=StringReplace(_NowDate(), '/', '-')



While 1
    $nMsg = GUIGetMsg()
    $citescini=IniReadSectionNames($x&".ini")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        case $cancelnewuser
            Exitloop
        case $createnewuser
            $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,1)
             If _ArrayFindAll($citescini,$Criptatuser) Then 
                $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,1)
                $a = IniWriteSection($x&".ini",$criptatuser, "password = " & $criptatpass)
                MsgBox( 4096, "User Doesn't Exist", "success")
            Else
                MsgBox( 4096, "Username Found", "Imposter! That username already exists!")
            EndIf


        case $button1
                GUISetState(@SW_DISABLE, $newuser)
                $LoginForm = GUICreate("Enter Username & Password", 298, 170, -1, -1)
                $LogInput = GUICtrlCreateInput("", 8, 40, 241, 21)
                $LogInPass = GUICtrlCreateInput("", 8, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                $OkLogin = GUICtrlCreateButton("&OK", 86, 128, 75, 25, $BS_NOTIFY)
                $ExitLogIn = GUICtrlCreateButton("Exit", 167, 128, 75, 25, $BS_NOTIFY)
                $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
                $LogUsername = GUICtrlCreateLabel("Enter Username", 8, 16, 80, 17)
                GUISetState(@SW_SHOW)


                While 1
                $citescini2 = IniReadSectionNames($x&".ini")
                $nMsg = GUIGetMsg()
                    Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                            ExitLoop

                        Case $exitlogin
                            exitloop

                        Case $okLogin
                        $decriptareuser = _StringEncrypt(1,Guictrlread($Loginput),$criptarekey,1)
                        If Not _ArrayFindAll($citescini2,$decriptareuser) Then
                            Msgbox(0,"a mers", "it work god help us")
                            $xa = IniReadSection($citescini2,$Decriptareuser)
                            $decriptarepass = _StringEncrypt(1,guictrlread($loginpass),$criptarekey,1)
                            if $xa[1][1] = $decriptarepass Then
                                msgbox(0,"auleo","You have succesfuly loged in")
                                msgbox(0,"0",$xa[1][1])
                            Else
                                msgbox(0,"seems","Wrong Password and username")
                            Endif
                        
                            
                        Else 
                            msgbox(0,"ss","Wrong username")
                        EndIf


                    EndSwitch
                WEnd
            GUISetState(@SW_ENABLE, $newuser)
            GUIDelete($LoginForm)


    EndSwitch
WEnd
Edited by mircea
Link to comment
Share on other sites

  • Moderators

- It doesn't matter how many underscores a function has. I use two underscores myself when It's a personal function inside my script that will never be used by another script.

- No idea what you mean by "stuck with the setError".

- My _IniCrypt* functions all have headers on what each of the parameters are.

_IniCrypt_Read() uses the same parameters as IniRead(). So that means that the "!#NOT-FOUND#!" parameter is what is returned if the "Section" ( $s_section ) or "Key" ( $s_user ) is not found. This lets me use a unique string to know when something doesn't exist yet.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

If @error Then Return SetError(-1, 0, 0) what does it give the -1,0,0

I'm not sure I'm still following your question.

I'm telling it to return me a specific error number ( whatever I want, but since it's ( the @error ) from another function I decided to use -1 to let me know where in the function it failed in case I need to debug, it's returning zero for the @extended info, and zero for a return value.

SetError() is defined and explained in the help file.

Essentially if you get -1, then you forgot to do the _IniCrypt_Initiate and the _IniCrypt_SetPassword functions.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

i fixed this problem,

heres the new code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <file.au3>
#include <Array.au3>
#include <string.au3>





$NewUser = GUICreate("New username", 209, 188, -1, -1)
$newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21)
$newpassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY)
$Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
$newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17)
$Button1 = GUICtrlCreateButton("Button1", 72, 160, 41, 25)
GUISetState(@SW_SHOW)

global $criptarekey = "parolasuperultrasecreta"
Global $x=StringReplace(_NowDate(), '/', '-')



While 1
    $nMsg = GUIGetMsg()
    $citescini=IniReadSectionNames($x&".ini")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        case $cancelnewuser
            Exitloop
        case $createnewuser
            $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,1)
             If _ArrayFindAll($citescini,$Criptatuser) Then
                $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,1)
                $a = IniWriteSection($x&".ini",$criptatuser, "password = " & $criptatpass)
                MsgBox( 4096, "User Doesn't Exist", "success")
            Else
                MsgBox( 4096, "Username Found", "Imposter! That username already exists!")
            EndIf


        case $button1
                GUISetState(@SW_DISABLE, $newuser)
                $LoginForm = GUICreate("Enter Username & Password", 298, 170, -1, -1)
                $LogInput = GUICtrlCreateInput("", 8, 40, 241, 21)
                $LogInPass = GUICtrlCreateInput("", 8, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                $OkLogin = GUICtrlCreateButton("&OK", 86, 128, 75, 25, $BS_NOTIFY)
                $ExitLogIn = GUICtrlCreateButton("Exit", 167, 128, 75, 25, $BS_NOTIFY)
                $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
                $LogUsername = GUICtrlCreateLabel("Enter Username", 8, 16, 80, 17)
                GUISetState(@SW_SHOW)


                While 1
                $citescini2 = IniReadSectionNames($x&".ini")
                $nMsg = GUIGetMsg()
                    Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                            ExitLoop

                        Case $exitlogin
                            exitloop

                        Case $okLogin
                        $decriptareuser = _StringEncrypt(1,Guictrlread($Loginput),$criptarekey,1)
                        If Not _ArrayFindAll($citescini2,$decriptareuser) Then
                            Msgbox(0,"a mers", "it work god help us")
                            $xa = IniReadSection($citescini2,$Decriptareuser)
                            $decriptarepass = _StringEncrypt(1,guictrlread($loginpass),$criptarekey,1)
                            If ControlGetText("","",$loginpass) = "" Then                           ;<==== checks for blank password(must be used before checking the password in the ini file)
                                MsgBox(4096, "Error", "Password must not be left blank!")           ;<==== alerts that the password was left blank
                                ExitLoop                                                            ;<==== exits the loop so it doesn't log you in
                            ElseIf $xa[1][1] = $decriptarepass Then
                                msgbox(0,"auleo","You have succesfuly loged in")
                                msgbox(0,"0",$xa[1][1])
                            Else
                                msgbox(0,"seems","Wrong Password and username")
                            Endif


                        Else
                            msgbox(0,"ss","Wrong username")
                        EndIf


                    EndSwitch
                WEnd
            GUISetState(@SW_ENABLE, $newuser)
            GUIDelete($LoginForm)


    EndSwitch
WEnd

i made it check for a blank password befor checking the decrypted password, it will close the login if password was left blank.

what i added:

If ControlGetText("","",$loginpass) = "" Then                           ;<==== checks for blank password(must be used before checking the password in the ini file)
                                MsgBox(4096, "Error", "Password must not be left blank!")           ;<==== alerts that the password was left blank
                                ExitLoop                                                            ;<==== exits the loop so it doesn't log you in

simple fix. glad you got it working now :unsure:

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Link to comment
Share on other sites

Thank you @pieeater i addes your modifications to create username too and password

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <file.au3>
#include <Array.au3>
#include <string.au3>





$NewUser = GUICreate("New username", 209, 188, -1, -1)
$newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21)
$newpassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY)
$Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
$newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17)
$Button1 = GUICtrlCreateButton("Button1", 72, 160, 41, 25)
GUISetState(@SW_SHOW)

global $criptarekey = "parolasuperultrasecreta"
Global $x=StringReplace(_NowDate(), '/', '-')



While 1
    $nMsg = GUIGetMsg()
    $citescini=IniReadSectionNames($x&".ini")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        case $cancelnewuser
            Exitloop
        case $createnewuser
            if ControlGetText("","",$newuserinput) = "" or ControlGetText("","",$newpassinput) = "" then 
                msgbox(0,"Error", "Username/Password can't be blank")
            Else 
                $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,1)
                If _ArrayFindAll($citescini,$Criptatuser) Then
                    $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,1)
                    $a = IniWriteSection($x&".ini",$criptatuser, "password = " & $criptatpass)
                    MsgBox( 4096, "User Doesn't Exist", "success")
                    
                        
                Else
                    MsgBox( 4096, "Username Found", "Imposter! That username already exists!")
                EndIf
            Endif


        case $button1
                GUISetState(@SW_DISABLE, $newuser)
                $LoginForm = GUICreate("Enter Username & Password", 298, 170, -1, -1)
                $LogInput = GUICtrlCreateInput("", 8, 40, 241, 21)
                $LogInPass = GUICtrlCreateInput("", 8, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                $OkLogin = GUICtrlCreateButton("&OK", 86, 128, 75, 25, $BS_NOTIFY)
                $ExitLogIn = GUICtrlCreateButton("Exit", 167, 128, 75, 25, $BS_NOTIFY)
                $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
                $LogUsername = GUICtrlCreateLabel("Enter Username", 8, 16, 80, 17)
                GUISetState(@SW_SHOW)


                While 1
                $citescini2 = IniReadSectionNames($x&".ini")
                $nMsg = GUIGetMsg()
                    Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                            ExitLoop

                        Case $exitlogin
                            exitloop

                        Case $okLogin
                        $decriptareuser = _StringEncrypt(1,Guictrlread($Loginput),$criptarekey,1)
                        
                        If Not _ArrayFindAll($citescini2,$decriptareuser) Then
                            Msgbox(0,"a mers", "it work god help us")
                            $xa = IniReadSection($citescini2,$Decriptareuser)
                            $decriptarepass = _StringEncrypt(1,guictrlread($loginpass),$criptarekey,1)
                            If ControlGetText("","",$loginpass) = "" Then                           ;<==== checks for blank password(must be used before checking the password in the ini file)
                                MsgBox(4096, "Error", "Password must not be left blank!")           ;<==== alerts that the password was left blank
                                ExitLoop                                                            ;<==== exits the loop so it doesn't log you in
                            ElseIf $xa[1][1] = $decriptarepass Then
                                msgbox(0,"auleo","You have succesfuly loged in")
                                msgbox(0,"0",$xa[1][1])
                            Else
                                msgbox(0,"seems","Wrong Password and username")
                            Endif
                        Elseif ControlGetText("","",$loginput) = "" Then
                            MsgBox(0,"please introduce","a damn username")

                        Else
                            msgbox(0,"ss","Wrong username")
                        EndIf


                    EndSwitch
                WEnd
            GUISetState(@SW_ENABLE, $newuser)
            GUIDelete($LoginForm)


    EndSwitch
WEnd
Link to comment
Share on other sites

Hello guys, seems like everything was working fine until i bin again stuck with something, now i dont understand why it dosen't write in the ini file.

- the problem it's that it dosen't give me any error so i putted a lot of msgbox to see if everything it's working fine, and it is but no error and it dosen't write the new password in the ini. file

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <file.au3>
#include <array.au3>
#include <string.au3>

Global $criptarekey = "parolasuperultrasecreta"
Global $x=StringReplace(_NowDate(), '/', '-')
Global $passlevel = "1" ;if i will ever want to change the level of protection of _stringencrypt

                        $PasswordForm = GUICreate("Change Password", 259, 211, -1, -1)
                        $PasswordOld = GUICtrlCreateInput("", 8, 32, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                        $PasswdOk = GUICtrlCreateButton("&OK", 38, 168, 75, 25, $BS_NOTIFY)
                        $PasswdCancel = GUICtrlCreateButton("&Cancel", 127, 168, 75, 25, $BS_NOTIFY)
                        $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 12, 77, 17, 0)
                        $Passwordnew = GUICtrlCreateInput("", 8, 88, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                        $Passwordnew2 = GUICtrlCreateInput("", 8, 136, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                        $Passwordnewlabel = GUICtrlCreateLabel("Enter the new password", 8, 64, 118, 17)
                        $passwordnewlabel2 = GUICtrlCreateLabel("Repeat the new password", 8, 112, 128, 17)
                        GUISetState(@SW_SHOW)
            
            
                            While 1
                                $citescini3 = IniReadSectionNames("accounts.ini")
                                $nMsg = GUIGetMsg()
                                Switch $nMsg
                                    Case $GUI_EVENT_CLOSE
                                        ExitLoop
                                    Case $PasswdCancel
                                        ExitLoop
                                    Case $passwdok
                                        $parolaveche = IniReadSection("accounts.ini",$decriptareuser)
                                        msgbox(0,"Test",$parolaveche[1][1]) ; for checking  if it's read the new password
                                        $codareparola = _StringEncrypt(1,Guictrlread($Passwordold),$criptarekey,1)
                                        if ControlGetText("","",$PasswordOld) = "" or ControlGetText("","",$passwordnew2) = "" or ControlGetText("","",$passwordnew) = "" then 
                                            msgbox (0,"Error", "You can't leave blank any input box")
                                        Else 
                                            If Not _ArrayFindAll($citescini3,$decriptareuser) Then
                                                msgbox(0,"Am ajuns","am ajuns") ; [this step works 
                                                if $parolaveche[1][1] = $codareparola Then ;this step works
                                                    Msgbox(0,"oau", "Merge verificat parola veche cu actuala")
                                                    if Guictrlread($Passwordnew) = guictrlread($passwordnew2) Then
                                                        msgbox(0,"Oau","E la fel nu e gresita") ; [this step works] 
                                                        $citescnouaparola = guictrlread($passwordnew2)
                                                        $scriunouaparola = _StringEncrypt(1,$citescnouaparola,$criptarekey,1)
                                                        msgbox(0,"hmmm",$scriunouaparola) ; checking if it's working
                                                        msgbox(0,"asd",$decriptareuser) ; checking if its working 
                                                        iniwritesection($citescini3,$decriptareuser,"password = " & $scriunouaparola) ; here it's my main problem, i dont understand why it dosen't write in the ini file
                                                        msgbox(0,"am scris","am scris noua parola")
                                                    Else
                                                        msgbox(0,"shit","nu nu merge") 
                                                    Endif
                                                Else
                                                    msgbox(0,"oau", "nu merge ai scris gresit")
                                                Endif
                                                
                                            endif
                                        endif
                                    
                                    
                                        

                                EndSwitch
                            WEnd ;;sfarsit buton de change
Link to comment
Share on other sites

try adding:

Global $parolaveche = IniReadSection("accounts.ini",$decriptareuser)

befor using it. ive had errors like this and all i had to do was make it a global before i used it. i don't know why it does it. also its giving me the error $decriptareuser not defined, so make sure your defining it or it wont work.

[spoiler]My UDFs: Login UDF[/spoiler]

Link to comment
Share on other sites

Still dosen't work but i putted the full code of the aplication.

The purpose of the aplication is that specific usernames can create other usernames (and passwords) and thouse accounts (all of them) can repair or add defect of some machine (that we call emulator).

The aplication is still under developing now im working on guictrlcreate radio, and im having there some dificulties but i hope that i will resolve it later

here is the accounts.ini file data the username is 1 and the password is 1

[9C40]
password = 9C40

here is the full code of aplication

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <file.au3>
#include <array.au3>
#include <string.au3>






                    

Global $criptarekey = "parolasuperultrasecreta"
Global $x=StringReplace(_NowDate(), '/', '-')
Global $timp = _nowtime(3)
Global $passlevel = "1"

;; inceput de LogIn

$LoginForm = GUICreate("Enter Username & Password", 298, 170, -1, -1)
$LogInput = GUICtrlCreateInput("", 8, 40, 241, 21)
$LogInPass = GUICtrlCreateInput("", 8, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$OkLogin = GUICtrlCreateButton("&OK", 86, 128, 75, 25, $BS_NOTIFY)
$ExitLogIn = GUICtrlCreateButton("Exit", 167, 128, 75, 25, $BS_NOTIFY)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
$LogUsername = GUICtrlCreateLabel("Enter Username", 8, 16, 80, 17)
GUISetState(@SW_SHOW)

;; parola si username-ul e 1 cifra 1


While 1
    $citescini2 = IniReadSectionNames("accounts.ini")
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $okLogin
            if ControlGetText("","",$loginpass) = "" or ControlGetText("","",$loginput) = "" then 
                msgbox(0,"Error", "Username/Password can't be blank")
            

            Else 
                Global $decriptareuser = _StringEncrypt(1,Guictrlread($Loginput),$criptarekey,1)
                If Not _ArrayFindAll($citescini2,$decriptareuser) Then
                
                $xa = IniReadSection($citescini2,$Decriptareuser)
                $decriptarepass = _StringEncrypt(1,guictrlread($loginpass),$criptarekey,1)
                Global $loginn = _StringEncrypt(0,$decriptareuser,$criptarekey,$passlevel) ;;username-ul celui care s-a logat
                    If ControlGetText("","",$loginpass) = "" Then                           
                        MsgBox(4096, "Error", "Password must not be left blank!")           
                        ExitLoop    
                
                    ElseIf $xa[1][1] = $decriptarepass Then


                
            Guidelete($LoginForm)
            ;; inceput de main 
            $Main = GUICreate("Emulator Repair v.0.5", 283, 198, 204, 135)
            Global $Username = GUICtrlCreateLabel($loginn& ":Has logged in", 8, 16, 124, 17) ;;aici arata numele
            $Change = GUICtrlCreateButton("Change Password", 144, 8, 97, 25)
            Global $EmulatorSerial = GUICtrlCreateInput("", 8, 56, 257, 21)
            $Read = GUICtrlCreateButton("Read", 8, 96, 73, 25)
            $Emulator = GUICtrlCreateButton("Emulator", 96, 96, 81, 25)
            $Addnewusername = GUICtrlCreateButton("Add  New Username", 80, 136, 105, 33)
            $Logs = GUICtrlCreateButton("Logs", 192, 96, 73, 25)

            GUISetState(@SW_SHOW)


            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        Exit
                    Case $Read
                            Msgbox(0,"Testat","Testat")
                        
                        
                    Case $Change ;; buton change password
                        GUISetState(@SW_DISABLE, $Main) ;; Inceput Cod Change password
                        $PasswordForm = GUICreate("Change Password", 259, 211, -1, -1)
                        $PasswordOld = GUICtrlCreateInput("", 8, 32, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                        $PasswdOk = GUICtrlCreateButton("&OK", 38, 168, 75, 25, $BS_NOTIFY)
                        $PasswdCancel = GUICtrlCreateButton("&Cancel", 127, 168, 75, 25, $BS_NOTIFY)
                        $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 12, 77, 17, 0)
                        $Passwordnew = GUICtrlCreateInput("", 8, 88, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                        $Passwordnew2 = GUICtrlCreateInput("", 8, 136, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                        $Passwordnewlabel = GUICtrlCreateLabel("Enter the new password", 8, 64, 118, 17)
                        $passwordnewlabel2 = GUICtrlCreateLabel("Repeat the new password", 8, 112, 128, 17)
                        GUISetState(@SW_SHOW)
            
            
                            While 1
                                $citescini3 = IniReadSectionNames("accounts.ini")
                                $nMsg = GUIGetMsg()
                                Switch $nMsg
                                    Case $GUI_EVENT_CLOSE
                                        ExitLoop
                                    Case $PasswdCancel
                                        ExitLoop
                                    Case $passwdok
                                        Global $parolaveche = IniReadSection("accounts.ini",$decriptareuser)
                                        msgbox(0,"Test",$parolaveche[1][1]) ; for checking  if it's read the new password
                                        $codareparola = _StringEncrypt(1,Guictrlread($Passwordold),$criptarekey,1)
                                        if ControlGetText("","",$PasswordOld) = "" or ControlGetText("","",$passwordnew2) = "" or ControlGetText("","",$passwordnew) = "" then 
                                            msgbox (0,"Error", "You can't leave blank any input box")
                                        Else 
                                            If Not _ArrayFindAll($citescini3,$decriptareuser) Then
                                                msgbox(0,"Am ajuns","am ajuns") ; [this step works 
                                                if $parolaveche[1][1] = $codareparola Then ;this step works
                                                    Msgbox(0,"oau", "Merge verificat parola veche cu actuala")
                                                    if Guictrlread($Passwordnew) = guictrlread($passwordnew2) Then
                                                        msgbox(0,"Oau","E la fel nu e gresita") ; [this step works] 
                                                        $citescnouaparola = guictrlread($passwordnew2)
                                                        $scriunouaparola = _StringEncrypt(1,$citescnouaparola,$criptarekey,1)
                                                        msgbox(0,"hmmm",$scriunouaparola) ; checking if it's working
                                                        msgbox(0,"asd",$decriptareuser) ; checking if its working 
                                                        iniwritesection($citescini3,$decriptareuser,"password = " & $scriunouaparola) ; here it's my main problem, i dont understand why it dosen't write in the ini file
                                                        
                                                        msgbox(0,"am scris","am scris noua parola")
                                                    Else
                                                        msgbox(0,"shit","nu nu merge") 
                                                    Endif
                                                Else
                                                    msgbox(0,"oau", "nu merge ai scris gresit")
                                                Endif
                                                
                                            endif
                                        endif
                                    
                                    
                                        

                                EndSwitch
                            WEnd ;;sfarsit buton de change
                            GUISetState(@SW_ENABLE, $Main)
                            GUIDelete($PasswordForm)
            
            
                    case $Emulator      ;; Inceput cod Emulator
                        GUISetState(@SW_DISABLE, $Main) 
                        $timp2 = _nowtime()
                        
                        $Emulators = GUICreate("Emulators", 617, 136, 278, 730)
                        $Nume = GUICtrlCreateLabel("Nume", 48, 8, 32, 17) 
                        $Data = GUICtrlCreateLabel("Data", 160, 8, 27, 17) 
                        $Ora = GUICtrlCreateLabel("Ora", 248, 8, 21, 17) 
                        $SerieEmulator = GUICtrlCreateLabel("Seria Emulatorului", 328, 8, 88, 17) 
                        $Reparat = GUICtrlCreateLabel("Reparat", 440, 8, 42, 17) 
                        $Defect = GUICtrlCreateLabel("Defect", 496, 8, 36, 17)
                        $NumeInput = GUICtrlCreateInput($loginn, 8, 32, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; numele se va lua automat de la LogIN (cand persoana respectiva se logheaza)
                        $DataInput = GUICtrlCreateInput($x, 136, 32, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; data curenta cand face modificarea
                        $OraInput = GUICtrlCreateInput($timp2, 232, 32, 65, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; ora curenta cand face modificarea
                        $SeriaInput = GUICtrlCreateInput(Guictrlread($EmulatorSerial), 312, 32, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; serialul care l-a folosit la main
                        $AddDefect = GUICtrlCreateButton("Add", 56, 72, 81, 25) 
                        $CancelEmulator = GUICtrlCreateButton("Cancel", 160, 72, 105, 25)
                        $MyLogs = GUICtrlCreateButton("My Logs", 288, 72, 81, 25)
                        $ReparatBox = GUICtrlCreateRadio("", 448, 32, 17, 17)
                        $DefectBox = GUICtrlCreateRadio("", 504, 32, 17, 17)
                        GUISetState(@SW_SHOW)


                        While 1
                            $nMsg = GUIGetMsg()
                            Switch $nMsg
                                Case $GUI_EVENT_CLOSE
                                    ExitLoop
                                Case $CancelEmulator
                                    Exitloop
                                Case $addDefect
                                    if Guictrlread($seriainput) = "" Then
                                        Msgbox(0,"Error","You didn't scan the serial of the emulator")
                                        
                                    Else
                                        msgbox(0,"test",$Defectinput)
                                        ;aici trebuie sa verificam daca Reparat radio sau Defect Radio are date sau nu, daca nu are apare eroare ca nu are si trebuie introduse
                                        ;pentru loguri vom folosi comanda _FileWriteLog
                                    endif
                                    
                                    
                                Case $Reparatbox ;; inceput cod Reparat
                                    GUISetState(@SW_DISABLE, $Emulators)    
                                    $Reparatform = GUICreate("Reparat", 412, 482, 302, 218)
                                    $ReparatLabel = GUICtrlCreateLabel("Reparat", 32, 16, 89, 33)
                                    GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
                                    $DefectLabel = GUICtrlCreateLabel("Defect", 32, 72, 43, 20)
                                    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
                                    Global $Defectinput = GUICtrlCreateInput("", 144, 72, 201, 21)
                                    $PiesaLabel = GUICtrlCreateLabel("Piesa Schimbata 1", 32, 104, 92, 17)
                                    $PiesaInput1 = GUICtrlCreateInput("", 144, 104, 201, 21)
                                    $PiesaLabel2 = GUICtrlCreateLabel("Piesa Schimbata 2", 32, 136, 92, 17)
                                    $PiesaInput2 = GUICtrlCreateInput("", 144, 136, 201, 21)
                                    $PiesaLabel3 = GUICtrlCreateLabel("Piesa Schimbata 3", 32, 168, 92, 17)
                                    $PiesaInput3 = GUICtrlCreateInput("", 144, 168, 201, 21)
                                    $Repara = GUICtrlCreateButton("Reparat", 88, 440, 97, 25)
                                    $Anuleaza = GUICtrlCreateButton("Anuleaza", 232, 440, 105, 25)
                                    $Testat = GUICtrlCreateRadio("Testat", 56, 200, 65, 25)
                                    $Netestat = GUICtrlCreateRadio("Netestat", 136, 200, 73, 25)
                                    $InformatiiRepair = GUICtrlCreateEdit("", 72, 232, 273, 193, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
                                    GUISetState(@SW_SHOW)
                                    GUICtrlSetState($Testat, $GUI_CHECKED)

                                        While 1
                                            $nMsg = GUIGetMsg()
                                            Switch $nMsg
                                                Case $GUI_EVENT_CLOSE
                                                    ExitLoop
                                                Case $Anuleaza
                                                    ExitLoop
                                                Case $repara
                                                    
                                                    if ControlGetText("","",$DefectInput) = "" or ControlGetText("","",$InformatiiRepair) = ""  Then
                                                        msgbox(0,"Error","You have to introduce Defect/Information in the edit table")
                                                    Else            ; here starts the writing the log files what i have write .                                         
                                                        if guictrlread($testat) = $GUI_CHECKED then 
                                                            msgbox(0,"Testat","A Fost testat")
                                                        Else 
                                                            If guictrlread($netestat) = $GUI_CHECKED then 
                                                                msgbox(0,"netestat","A fost netestat")
                                                            endif 
                                                        EndIf
                                                            
                                                    Endif

                                                    

                                            EndSwitch
                                        WEnd        ;;Sfarsit Cod Reparat
                                        GUISetState(@SW_ENABLE, $Emulators)
                                        GUIDelete($ReparatForm)
                                        
                                Case $DefectBox ;;Defect box
                                    GUISetState(@SW_DISABLE, $Emulators)
                                    $Defectform = GUICreate("Defect Form", 405, 396, 757, 401)
                                    $DefecLabel = GUICtrlCreateLabel("Add Defect", 32, 16, 122, 33)
                                    GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
                                    $DefectLabel = GUICtrlCreateLabel("Defect", 32, 72, 43, 20)
                                    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
                                    $Defectinput = GUICtrlCreateInput("", 104, 72, 273, 21)
                                    $Informatiilabel = GUICtrlCreateLabel("Informations", 32, 128, 61, 17)
                                    GUICtrlCreateEdit("", 104, 128, 273, 193, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
                                    $AddDefect = GUICtrlCreateButton("Add Defect", 120, 352, 73, 25)
                                    $CancelDefect = GUICtrlCreateButton("Cancel", 256, 352, 73, 25)
                                    GUISetState(@SW_SHOW)


                                        While 1
                                        $nMsg = GUIGetMsg()
                                            Switch $nMsg
                                                Case $GUI_EVENT_CLOSE
                                                    ExitLoop
                                                Case $cancelDefect
                                                    exitloop

                                            EndSwitch
                                        WEnd    
                                        GUISetState(@SW_ENABLE, $Emulators)
                                        GUIDelete($DefectForm) ;;Sfarsit defectbox
                                        
                                ;Case $Mylogs ;; inceput pt mylogs
                                        
                                        
                                    
                            EndSwitch
                        WEnd ;;Sfarsit cod Emulator

                        GUISetState(@SW_ENABLE, $Main)
                        GUIDelete($Emulators)   
                        
                Case $Addnewusername 
                    GUISetState(@SW_DISABLE, $Main) ;; inceput newuserform
                    
                    $NewUser = GUICreate("New username", 209, 188, -1, -1)
                    $newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21)
                    $newpassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
                    $Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY)
                    $Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY)
                    $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0)
                    $newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17)
                    GUISetState(@SW_SHOW)
                    $citescini=IniReadSectionNames("accounts.ini")
                        While 1
                        $nMsg = GUIGetMsg()
                            Switch $nMsg
                                Case $GUI_EVENT_CLOSE
                                    ExitLoop
                                case $cancelnewuser
                                    Exitloop
                                case $createnewuser
                                    if ControlGetText("","",$newuserinput) = "" or ControlGetText("","",$newpassinput) = "" then 
                                        msgbox(0,"Error", "Username/Password can't be blank")
                                    Else 
                                        $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,1)
                                        If _ArrayFindAll($citescini,$Criptatuser) Then
                                            $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,1)
                                            $a = IniWriteSection($x&".ini",$criptatuser, "password = " & $criptatpass)
                                            MsgBox( 4096, "User Doesn't Exist", "success")
                                            
                                        Else
                                            MsgBox( 4096, "Username Found", "Imposter! That username already exists!")
                                        EndIf
                                    Endif

            

                            EndSwitch
                        WEnd    
                    GUISetState(@SW_ENABLE, $Main)
                    GUIDelete($Newuser) ;;sfarsit newuser form
                EndSwitch
            WEnd ;;Sfarsit main
                    Else
                        msgbox(0,"Error","Wrong Password/username")
                    Endif
            

                Else
                    msgbox(0,"Error","Wrong username/password")
                EndIf
            Endif
        case $exitLogIn
                Exit
            
    EndSwitch
WEnd ;;Sfarsit de log in
Link to comment
Share on other sites

  • Moderators

1. StringEncrypt is really slow, thus the reason most of use the Crypt.au3 or our own encryption dll's ( and the reason I made the Ini Crypt stuff for people like yourself that don't use databases ).

2. $citescini3 is an array, in your IniWrite(), you're treating it as a string.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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