Jump to content

Recommended Posts

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)


While 1

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


Func _Exit()

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")

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)


How can I achieve that please?

Thanks in advance :)

Edited by 31290

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

Link to post
Share on other sites
  • Developers

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.


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.

Link to post
Share on other sites

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

Link to post
Share on other sites

@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

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By izmegna
      I am trying to auto login to web app that has the following HTML for the username, password and submit button:
      <input name="usernameField" tabindex="0" class="inp" id="usernameField" type="text" value="" message="FND_SSO_USER_NAME">
      <input name="passwordField" tabindex="0" class="inp" id="passwordField" type="password" value="" message="FND_SSO_PASSWORD">
      <button tabindex="0" class="OraButton left" style="padding-right: 6px; padding-left: 6px;" onclick="submitCredentials()" message="FND_SSO_LOGIN">Log In</button>
      Following is the AutoIT script I am using I am passing the username and password via cmd but it is not working, any suggestion?
      #include <IE.au3>
      Local $url ="https://www.Intra.edwa.com"
      Local $oIE =_IECreate($url)
      Local $oUser =_IEGetObjById($oIE,"usernameField")
      Local $oPass =_IEGetObjById($oIE,"passwordField")
      _IEFormElementSetValue($oUser, $CmdLine[1])
      _IEFormElementSetValue($oPass, $CmdLine[2])
      $oLinks = _IETagNameGetCollection($oIE, "input")
      For $oLink In $oLinks
          If String($oLink.type) = "submit" And String($oLink.value) = "Sign In" Then
                _IEAction($oLink, "click")
    • By hek
      Hey everyone,
      Was wondering how I would be able to implement this on a local computer instead of using connectserver? 
      Any suggestions or help would be appreciated. Thanks. 
    • By Stormgrade
      I'm french, sorry for my english.
      I release my project, a password manager : Password Keeper
      First I would like to thanks Guinness and Melba23 for their help, and I'm very sorry for those I forget, please remind me to add you.
      Well my program manage and crypt passwords, first I understand if you don't trust me for this kind of sensible software, but I remember you that all the the source files are at your disposal, fell free to explore them.
      The login is : admin and you can change it later
      How it work ? see Methode de cryptage en BDD.pdf in french

      The main interface
      You can obviously add,modify and delete your entry, also you can search with keywords

      A password generator is included

      I won't update it anymore.
      It's a BSD license.
      Autoit version :
      Have a good day.
      Methode de cryptage en BDD.pdf Passwordkeeper.7z
    • By nacerbaaziz
      hello all, and welcome to this tool
      the NB-Password_generator is a small tool which allow you to create a strong passwords
      with this tool you can create a random passwords using :
      1. capital letters
      2. small letters
      3. numbers
      4. symbols
      be sure that you can check any option that  you want and uncheck what you don't want to use
      this tool allow you to create a password from 6 letters to 150 lettersNB-Password_generator.zip
      at the end please accept my greetings
      am waiting for your commants
    • By nooneclose
      I am sure you guys know of a simple solution but I am still kind of new to AutoIt and its special functions. I want my code to be able to know how to encrypt and decrypt "A" and "a" as two different chars.
      my code is very long so here is just a snippet/example of it.  
      ;Encode== Global $charAA = "" ; ( Capital letter A ) = Global 184 = ¸ ( Cedilla ) $charAA = $charAA & Chr(65) Global $chara = "" ; ( Lowercase letter a ) = Global 251 = û ( û Latin Small Letter U With Circumflex ) $chara = $chara & Chr(97) ;Decode== Global $ch184 = "" ;( Copyright symbol ) = $charAA $ch184 = $ch184 & Chr(184) Global $ch251 = "" ;( û Latin Small Letter U With Circumflex ) = $chara $ch251 = $ch251 & Chr(251) ;Encode== stringreplace($test_String, $charAA, $ch184) stringreplace($test_String, $chara, $ch251) ;Decode== stringreplace($$new_String, $ch184, $charAA) stringreplace($$new_String, $ch251, $chara) ( NOTE: my stringreplace function is nested in my actual code. I only separated them here for readability. )

      I know there are better ways to Encrypt and Decrypt a message but I'm doing this as a fun side project for me and a select group of friends to enjoy. 
      Again My code is not encrypting or decrypting capitals and lower case properly even though I use their ANSI codes. 
      Example: Input "A a B b"  Encrypt: ". . $ $"  Decrypt: "A A B B"
      Any and all help will be greatly appreciated.  
  • Create New...