DannyJ Posted June 29, 2021 Share Posted June 29, 2021 I am writing a program that checks, that a string is okay for a password. I need to chechk that the string contains at least a number a capital letter and a special charachter? Here is my example code: $Input = InputBox(64,"Type password","") If GUICtrlRead($Input) == "" Or $Input .... CHECK Then MsgBox(0,"password","password not okay") Else MsgBox(0,"okay","password okay") EndIf Link to comment Share on other sites More sharing options...
Solution Nine Posted June 29, 2021 Solution Share Posted June 29, 2021 (edited) Maybe this ? $Input = InputBox("Title","Type password","") If @error Then Exit If StringRegExp($Input, "[A-Z]") And StringRegExp($Input, "[0-9]") And StringRegExp($Input,"[!/$%?&*+=]") Then MsgBox(0,"password","password is OK") Else MsgBox(0,"okay","password not okay") EndIf Or even this better : $Input = InputBox("Title","Type password","") If @error Then Exit If StringRegExp($Input, "(?=.*[A-Z])(?=.*[0-9])(?=.*[!/$%?&*+=])") Then MsgBox(0,"password","password is OK") Else MsgBox(0,"okay","password not okay") EndIf Edited June 29, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
DannyJ Posted June 29, 2021 Author Share Posted June 29, 2021 Thank you very much @Nine Link to comment Share on other sites More sharing options...
JockoDundee Posted June 29, 2021 Share Posted June 29, 2021 8 hours ago, DannyJ said: I need to chechk that the string contains at least a number a capital letter and a special charachter? So a password could contain just UPPERCASE letters, a number and a special char? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
spudw2k Posted June 30, 2021 Share Posted June 30, 2021 Per the requirements listed, yes. As a good security practice, a minimum length is also advised; for example, 8 characters. *built from @Nine's example $Input = InputBox("Title","Type password","") If @error Then Exit If StringRegExp($Input, "(?=^.{8,}$)(?=.*[A-Z])(?=.*[0-9])(?=.*[[:punct:]])") Then MsgBox(0,"password","password is OK") Else MsgBox(0,"okay","password not okay") EndIf Skysnake 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
jchd Posted June 30, 2021 Share Posted June 30, 2021 FYI you can also use the Unicode Character Properties supported by the regex engine. See help. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
JockoDundee Posted June 30, 2021 Share Posted June 30, 2021 4 hours ago, spudw2k said: Per the requirements listed, yes. Interesting. Yet an ALL-CAPS password can be guessed by brute force just as quickly as an all-lower case password. And since I doubt that the omission of the requirement of mixed case is at the request of the user community, perhaps it’s just an oversight… Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
spudw2k Posted June 30, 2021 Share Posted June 30, 2021 I agree, password complexity (strong passwords) can (and should) be adequate to thwart brute-forcing as much as reasonable. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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