#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=favicon.ico #AutoIt3Wrapper_Res_Description=Oplop (One password, lots of passwords) for Windows #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_Language=1033 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Region application setup #include #include #include Opt("GUIOnEventMode", 1) ; Enable OnEvent mode Opt('MustDeclareVars', 1) Global $ProgName = "OpLop for Windows", $GUIWidth = 313, $GUIHeight = 250 Global $EnterNicknameLabel, $NicknameEdit, $EnterMasterPasswordLabel, $MasterPasswordEdit, $AccountPasswordLabel, $AccountPasswordEdit, $EightCharPasswordLabel, $EightCharPasswordEdit, $ButtonOk, $ButtonCancel, $ButtonStartOver #EndRegion application setup #Region GUI creation GUICreate($ProgName, $GUIWidth, $GUIHeight, -1, -1) $EnterNicknameLabel = GUICtrlCreateLabel("Nickname:", 20, 10) $NicknameEdit = GUICtrlCreateInput("", 20, 30, 270, 20) GUICtrlSetTip($NicknameEdit, "Please fill out this field.") $EnterMasterPasswordLabel = GUICtrlCreateLabel("Master value:", 20, 55) $MasterPasswordEdit = GUICtrlCreateInput("", 20, 75, 270, 20, $ES_PASSWORD) GUICtrlSetTip($MasterPasswordEdit, "Please fill out this field.") $AccountPasswordLabel = GUICtrlCreateLabel("Derived value:", 20, 100) GUICtrlSetState($AccountPasswordLabel,$GUI_HIDE) $AccountPasswordEdit = GUICtrlCreateInput("", 20, 120, 270, 20, $ES_READONLY) GUICtrlSetState($AccountPasswordEdit,$GUI_HIDE) $EightCharPasswordLabel = GUICtrlCreateLabel("1st 8 characters of the derived value:", 20, 185) GUICtrlSetState($EightCharPasswordLabel, $GUI_HIDE) $EightCharPasswordEdit = GUICtrlCreateInput("", 20, 205, 270, 20, $ES_READONLY) GUICtrlSetState($EightCharPasswordEdit, $GUI_HIDE) $ButtonOk = GUICtrlCreateButton("&Generate", 20, 150, 120, 25) GUICtrlSetOnEvent($ButtonOk, "OKButton") $ButtonCancel = GUICtrlCreateButton("&Quit", 170, 150, 120, 25) GUICtrlSetOnEvent($ButtonCancel, "CLOSEButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton") $ButtonStartOver = GUICtrlCreateButton("&Start Over", 20, 150, 120, 25) GUICtrlSetOnEvent($ButtonStartOver, "StartOverButton") GUICtrlSetState($ButtonStartOver, $GUI_HIDE) ;need to create a copy button GUISetState(@SW_SHOW) #EndRegion GUI creation While 1 Sleep(100) ; Sleep to reduce CPU usage WEnd Func OKButton() Local $bNickname = False Local $bPassword = False Local $needed = "" If GUICtrlRead($NicknameEdit) <> "" then $bNickname = True endif If GUICtrlRead($MasterPasswordEdit) <> "" then $bPassword = True endif If Not $bNickname Then GUICtrlSetState($NicknameEdit, $GUI_FOCUS) ElseIf Not $bPassword Then GUICtrlSetState($MasterPasswordEdit, $GUI_FOCUS) ElseIf $bNickname And $bPassword Then $needed = Oplop(GUICtrlRead($MasterPasswordEdit),GUICtrlRead($NicknameEdit)) GUICtrlSetData($NicknameEdit, Null) GUICtrlSetData($MasterPasswordEdit, Null) GUICtrlSetData($AccountPasswordEdit, $needed) GUICtrlSetData($EightCharPasswordEdit, StringLeft($needed, 8)) $needed = Null GUICtrlSetState($NicknameEdit, $GUI_HIDE) GUICtrlSetState($MasterPasswordEdit, $GUI_HIDE) GUICtrlSetState($ButtonOk, $GUI_HIDE) GUICtrlSetState($AccountPasswordLabel,$GUI_SHOW) GUICtrlSetState($AccountPasswordEdit,$GUI_SHOW) GUICtrlSetState($ButtonStartOver, $GUI_SHOW) GUICtrlSetState($EightCharPasswordLabel, $GUI_SHOW) GUICtrlSetState($EightCharPasswordEdit, $GUI_SHOW) GUICtrlSetState($ButtonStartOver, $GUI_FOCUS) EndIf EndFunc ;==>OKButton Func StartOverButton() GUICtrlSetState($AccountPasswordLabel,$GUI_HIDE) GUICtrlSetState($AccountPasswordEdit,$GUI_HIDE) GUICtrlSetState($EightCharPasswordLabel, $GUI_HIDE) GUICtrlSetState($EightCharPasswordEdit, $GUI_HIDE) GUICtrlSetState($ButtonStartOver, $GUI_HIDE) GUICtrlSetData($MasterPasswordEdit, "") GUICtrlSetData($NicknameEdit, "") GUICtrlSetState($MasterPasswordEdit,$GUI_SHOW) GUICtrlSetState($NicknameEdit, $GUI_SHOW) GUICtrlSetState($ButtonOk, $GUI_SHOW) GUICtrlSetState($NicknameEdit, $GUI_FOCUS) EndFunc ;==>StartOverButton Func CLOSEButton() Exit EndFunc ;==>CLOSEButton Func Oplop($secret, $mnemonic) #cs Oplop cannon: 1. Concatenate the master password with the nickname (in that order) 2. Generate the MD5 has of that string. 3. Convert the MD5 hash to URL-safe Base64 4. See if there are any digits in the 1st 8 characters 4.1. Search for the first uninterrupted substring of digits 4.2. If a substring of digits is found, prepend them to the Base64 string 4.3. If no substring is found, prepend a 1 5. Use the first 8 characters as the account password. DonationCoder.com skwire and Ath - coded this function mouser supported the request #ce Local $i, $b = False Local $md5 = _Crypt_HashData($secret & $mnemonic , $CALG_MD5) Local $base64 = StringReplace(StringReplace(_Base64Encode($md5), "/","_"), "+","-") Local $r = "" For $i = 1 To 8 If StringRegExp(StringMid($base64, $i, 1), "\d") Then $b = True Next If Not $b Then $i = 8 While $i <= StringLen($base64) If StringRegExp(StringMid($base64, $i, 1), "\d") Then If Not $b Then $b = True $r &= StringMid($base64, $i, 1) Else $r &= StringMid($base64, $i, 1) EndIf Else If $b Then $i = StringLen($base64) EndIf $i += 1 WEnd EndIf ;Return StringLeft($r & $base64, 12) ;Return ($r & $base64) Return StringTrimRight($r & $base64, 2) EndFunc ;==>Oplop Func _Base64Encode($sData) #cs ; Name...........: _Base64Encode ; Description ...: Returns the given strinng encoded as a Base64 string. ; Syntax.........: _Base64Encode($sData) ; Parameters ....: $sData ; Return values .: Success - Base64 encoded string. ; Failure - Returns 0 and Sets @Error: ; |0 - No error. ; |1 - Could not create DOMDocument ; |2 - Could not create Element ; |3 - No string to return ; Author ........: Andrew ; Modified.......: ; Remarks .......: ; Related .......: _Base64Decode ; Link ..........; ; Example .......; Yes #ce Local $oXml = ObjCreate("Msxml2.DOMDocument") If Not IsObj($oXml) Then SetError(1, 1, 0) EndIf Local $oElement = $oXml.createElement("b64") If Not IsObj($oElement) Then SetError(2, 2, 0) EndIf $oElement.dataType = "bin.base64" $oElement.nodeTypedValue = Binary($sData) Local $sReturn = $oElement.Text If StringLen($sReturn) = 0 Then SetError(3, 3, 0) EndIf Return $sReturn EndFunc ;==>_Base64Encode #cs Func FutureTest($inbound) local $nGood ;$inbound = "T#sT1NG" #include #cs min password rules implementing this will take this program out of cannon for Oplop 8 characters only, valid characters for password are A-Z, a-z, 0-9, and $, @, # 3 of 4 of the following: Uppercase lowercase number spec char #ce ;test for at least one upper and set state test value to 1 if true If StringRegExp(StringLeft($inbound,8), '(?=.*[A-Z])') Then $nGood = $nGood + 1 Else $nGood = $nGood + 0 EndIf ;test for at least one lower and set state test value to 2 if true If StringRegExp(StringLeft($inbound,8), '(?=.*[a-z])') Then $nGood = $nGood + 2 Else $nGood = $nGood + 0 EndIf ;test for at least one number and set state test value to 4 if true If StringRegExp(StringLeft($inbound,8), '(?=.*[0-9])') Then $nGood = $nGood + 4 Else $nGood = $nGood + 0 EndIf ;test for at least one special and set state test value to 8 if true If StringRegExp(StringLeft($inbound,8), '(?=.*[$@#])') Then $nGood = $nGood + 8 Else $nGood = $nGood + 0 EndIf MsgBox($MB_OK,"FutureTest", $nGood) ;test the state of the testing, good values are 15,14,13,11,7 ;return 8 chars Return StringLeft($inbound, 8) EndFunc ;==>FutureTest #ce