Jump to content

Recommended Posts

Posted (edited)

Hi everyone, 

I'm building some script that will encrypt some user password and store it in an ini file.
I'd like to recall the password in a putty session but I can't figure out how to decrypt it:

So far, I have:

Global $Images = "C:\SAC_IS\ATL_Laptop\Resources\Images\"
Global $WorkingDir = "C:\SAC_IS\Switches_Toolbox\"
Global $Settings = $WorkingDir & "\Settings.ini"

DirCreate ($WorkingDir)

_FirstRun()

While 1
    Sleep(10)
WEnd

Func _FirstRun()
If FileExists ("C:\SAC_IS\Switches_Toolbox\Settings.ini") Then
_LoginfoGUI()
Else
MsgBox (64, "PUTTY EXECUTABLE", "First, select PUTTY.EXE path")
Global $PuttyPath = FileOpenDialog("Please indicate putty.exe path", @HomeDrive, "exe (*.exe)")
_LoginfoGUI()
If @Error Then
Global $Error = MsgBox(21, "Error!", "Can't find PUTTY.EXE!"& @CRLF & "Click Retry or Cancel to Quit")
If $Error = $IDRETRY Then
_FirstRun()
Else
_Exit()
EndIf
Else
FileInstall ("C:\Users\h74033\Desktop\Scirpts\Switches\Settings.ini", $WorkingDir & "\Settings.ini", 1)
IniWrite ($Settings, "Putty", "Path", $PuttyPath)
EndIf
EndIf
; SwitchesToolboxGui()

Endfunc

Func _Exit()
    Exit
EndFunc 

Func _LoginfoGUI()
Global $LoginfoGUI = GUICreate("Switches Toolbox Configuration", 300, 300, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $LoginfoGUI)
    GUICtrlCreatePic ($Images & "\SAClogo.jpg", 30, 10, 240, 80)
    GUISetBkColor ($Color_White)
    GUICtrlCreateLabel("-- SWITCHES TOOLBOX --", 85, 100, 150, 25)
    GUICtrlSetFont (-1, 8.5, 700, 0)
    GUICtrlCreateLabel("Please provide required information:", 10, 130, 250, 25)
    GUICtrlCreateLabel("-Global ID:", 10, 170, 60, 30)
    GUICtrlSetFont (-1, 8.5, 700, 0)
    GUICtrlCreateLabel("-Password:", 10, 210, 70, 30)
    GUICtrlSetFont (-1, 8.5, 700, 0)
    Global $GIDInput = GUICtrlCreateInput("", 90, 168, 80, 20)
    Global $PassInput = GUICtrlCreateInput("", 90, 205, 150, 20, $ES_PASSWORD)
    GUICtrlCreateButton ("Submit", 100, 245, 100, 25)
    GUICtrlSetOnEvent(-1, "_Submit")
    GUISetState(@SW_SHOW)
EndFunc

Func _Submit()
Global $GID = GuiCtrlRead($GIDInput)
Global $EncryptedPwd = _Crypt_HashData (GuiCtrlRead($PassInput), $CALG_MD2)

IniWrite ($Settings, "Username", "Gid", $Gid)
IniWrite ($Settings, "Encryption", "Password", $EncryptedPwd)
;MsgBox(0, "re", $EncryptedPwd)

EndFunc

How can I achieve that please?

Thanks in advance :)
 

Edited by 31290
Solved

~~~ Doom Shall Never Die, Only The Players ~~~

  • Developers
Posted

The UDF _Crypt_HashData() does not encrypt a string but creates an hash which you can later use to compare to another string by using the same functions.

So this is a safe way for example to verify a typed in password without being able to restore the original password.

Jos 
 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

Thanks to both of you for your answers.

@Jfish I took a look at the function you pointed out but I don't understand the "$vCryptKey" parameter. Can you please provide an example upon the script I made?

Thanks :)

EDIT: I found the solution. Thanks again for your help :)

  

 

Edited by 31290
Solution found.

~~~ Doom Shall Never Die, Only The Players ~~~

Posted

@Jfish I took a look at the function you pointed out but I don't understand the "$vCryptKey" parameter. Can you please provide an example upon the script I made?

  

 

Isn't there an example in the example? Would be the obvious place I would look

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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