helmar Posted July 2, 2015 Share Posted July 2, 2015 (edited) It has been a while since I wrote code for "others" and I was hoping someone could take a few minutes and see if I am doing this both efficiently and decently. I also want to ask about clearing out the inputted values from memory - how best to do that?expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <Crypt.au3> Opt('MustDeclareVars', 1) Global $ProgName = "Create Password", $EnterNicknameLabel, $NicknameEdit, $EnterMasterPasswordLabel, $MasterPasswordEdit, $AccountPasswordLabel, $AccountPasswordEdit, $ButtonOk, $ButtonStartOver, $ButtonCancel, $msg GUICreate($ProgName, 313, 200, -1, -1) ;title, height, width, left (-1 means centered), top (-1 means centered) $EnterNicknameLabel = GUICtrlCreateLabel("Nickname:", 20, 10) $NicknameEdit = GUICtrlCreateInput("", 20, 30, 270, 20, $ES_PASSWORD) $EnterMasterPasswordLabel = GUICtrlCreateLabel("Master password:", 20, 55) $MasterPasswordEdit = GUICtrlCreateInput("", 20, 75, 270, 20, $ES_PASSWORD) $AccountPasswordLabel = GUICtrlCreateLabel("Account password:", 20, 100) GUICtrlSetState($AccountPasswordLabel,$GUI_HIDE) $AccountPasswordEdit = GUICtrlCreateInput("", 20, 120, 270, 20, $ES_READONLY) GUICtrlSetState($AccountPasswordEdit,$GUI_HIDE) $ButtonOk = GUICtrlCreateButton("&OK", 20, 150, 120, 25) $ButtonStartOver = GUICtrlCreateButton("&Start Over", 20, 150, 120, 25) GUICtrlSetState($ButtonStartOver, $GUI_HIDE) $ButtonCancel = GUICtrlCreateButton("&Cancel", 170, 150, 120, 25) GUISetState() While 1 ; Run the GUI until the window is closed $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $ButtonOk If GUICtrlRead($NicknameEdit) = "" then ;no nickname entered MsgBox(0, $ProgName, "Please enter a nickname.") ContinueLoop endif If GUICtrlRead($MasterPasswordEdit) = "" then ;no password entered MsgBox(0, $ProgName, "Please enter a master password.") ContinueLoop endif GUICtrlSetData($AccountPasswordEdit,CreatePasswd(GUICtrlRead($MasterPasswordEdit),GUICtrlRead($NicknameEdit))) GUICtrlSetData($MasterPasswordEdit, "") GUICtrlSetData($NicknameEdit, "") GUICtrlSetState($NicknameEdit,$GUI_HIDE) GUICtrlSetState($MasterPasswordEdit,$GUI_HIDE) GUICtrlSetState($AccountPasswordLabel,$GUI_SHOW) GUICtrlSetState($AccountPasswordEdit,$GUI_SHOW) GUICtrlSetState($ButtonOk, $GUI_HIDE) GUICtrlSetState($ButtonStartOver, $GUI_SHOW) Case $msg = $ButtonStartOver GUICtrlSetState($AccountPasswordLabel,$GUI_HIDE) GUICtrlSetState($AccountPasswordEdit,$GUI_HIDE) GUICtrlSetState($ButtonStartOver, $GUI_HIDE) GUICtrlSetState($MasterPasswordEdit,$GUI_SHOW) GUICtrlSetState($NicknameEdit,$GUI_SHOW) GUICtrlSetState($ButtonOk, $GUI_SHOW) GUICtrlSetState($NicknameEdit, $GUI_FOCUS) Case $msg = $ButtonCancel ExitLoop EndSelect WEnd GUIDelete(); ; will return 1 Func CreatePasswd($secret, $mnemonic) ;this is just dummy function ;actual function does ensure 8 char password or greater is created ;the process isn't included here for brevity Return $secret & $mnemonic EndFuncThe actual password creation function is not included here, but does take into account complexity requirements, and min length of 8, and including special characters.Thanks in advance for all comments / thoughts / ideas. Edited July 2, 2015 by helmar explain things better Link to comment Share on other sites More sharing options...
Starstar Posted July 2, 2015 Share Posted July 2, 2015 (edited) It has been a while since I wrote code for "others"Good you are going to help others.............i tried your password Creator ........But you don't think this is useless... if you are going to guide those people who does not know to create a strong or very strong password then add something difficult to hack....suppose my nick name was jon and master password was 123 and your password creator is going to advise me use "123jon" as a password....and this password will be rejected by many Forum websites because it length is not so good it should be 8.Edit:::your script must be able to detect password length......that should be 8 or moreAt-least one alphabet must be capital in nickname or in master password.after applying tricks like this it make sense that the script is for helping user to create a strong or very strong password. Edited July 2, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
helmar Posted July 2, 2015 Author Share Posted July 2, 2015 Good you are going to help others............. after applying tricks like this it make sense that the script is for helping user to create a strong or very strong password. The actual "CreatePasswd" function does do what you recommend. I wrote this code so that I could have that function stand outside of the GUI logic. An example of resulting password would be "1_YXmLZv". Numbers, mixed case, special characters, 8 chars. I didn't include the actual function, both for brevity, and for ease of review. My questions are regarding GUI concepts (was I efficient) and clearing inputted values from memory (if possible). Link to comment Share on other sites More sharing options...
Starstar Posted July 2, 2015 Share Posted July 2, 2015 (edited) $NicknameEdit = Null $MasterPasswordEdit = NullAfter using the input variable just set them to null ........Like above example. Values will be automatically remove from random access memory. Edited July 2, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now