OmYcroN Posted April 18, 2009 Share Posted April 18, 2009 What i want to do : - read a file that contains ini sections of an ini file but encrypted using a function (is there one for it ?) - decrypt it and send the results to IniReadSection() (is it possible ?) I don't know how to make a function for crypt/decrypt and i'm not sure about the IniReadSection() that usese a file as parameter and not a text from a variable. In other words my file file.dat : #$G%$##%^GHG And using a function to decrypt it : [section] Key = Value And then pass this to IniReadSection() If u have other ideas for this tell me, please. Link to comment Share on other sites More sharing options...
oMBRa Posted April 18, 2009 Share Posted April 18, 2009 depends on the type of encryption Link to comment Share on other sites More sharing options...
Mat Posted April 18, 2009 Share Posted April 18, 2009 there is already encrypt, and it has decrypt built in... look in the help file for _StringEncrypt (under string management). it has it all there. you probably want to save the converted cop to a temporary file, and then read that... unless you want to declare all the keys etc your self!! Hope it helps Mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 18, 2009 Moderators Share Posted April 18, 2009 OmYcroN, Here is something from my snippets folder which you may find useful in your project:#include <String.au3> ; define encryption settings Global Const $enc_pass = "ABC123"; set the encryption password Global Const $enc_level = 2; set the encryption level (check the help file for _StringEncrypt for possible levels) ; you can use the functions in a similar manner to the default IniWrite and IniRead _IniWrite("data.ini", "settings", "foo", "bar") ConsoleWrite(_IniRead("data.ini", "settings", "foo", "OOPS!") & @CRLF) ; just like the default IniWrite Func _IniWrite($sIniPath, $sIniSection, $sIniKey, $sIniValue) IniWrite($sIniPath, $sIniSection, $sIniKey, _StrEncrypt($sIniValue)) EndFunc ;==>_IniWrite ; just like the default IniRead Func _IniRead($sIniPath, $sIniSection, $sIniKey, $sIniDefault) Return _StrDecrypt(IniRead($sIniPath, $sIniSection, $sIniKey, _StrEncrypt($sIniDefault))) EndFunc ;==>_IniRead ; Encrypt a string using the default $enc_pass and $enc_level Func _StrEncrypt($sString) Return _StringEncrypt(1, $sString, $enc_pass, $enc_level) EndFunc ;==>_StrEncrypt ; Decrypt a string using the default $enc_pass and $enc_level Func _StrDecrypt($sString) Return _StringEncrypt(0, $sString, $enc_pass, $enc_level) EndFunc ;==>_StrDecrypt M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
oMBRa Posted April 18, 2009 Share Posted April 18, 2009 (edited) as I have understood the ini sections are already encrypted so if they arent encrypted with the RC4 encryption _StringEncrypt wont work Edited April 18, 2009 by oMBra Link to comment Share on other sites More sharing options...
OmYcroN Posted April 18, 2009 Author Share Posted April 18, 2009 OmYcroN, Here is something from my snippets folder which you may find useful in your project:#include <String.au3> ; define encryption settings Global Const $enc_pass = "ABC123"; set the encryption password Global Const $enc_level = 2; set the encryption level (check the help file for _StringEncrypt for possible levels) ; you can use the functions in a similar manner to the default IniWrite and IniRead _IniWrite("data.ini", "settings", "foo", "bar") ConsoleWrite(_IniRead("data.ini", "settings", "foo", "OOPS!") & @CRLF) ; just like the default IniWrite Func _IniWrite($sIniPath, $sIniSection, $sIniKey, $sIniValue) IniWrite($sIniPath, $sIniSection, $sIniKey, _StrEncrypt($sIniValue)) EndFunc ;==>_IniWrite ; just like the default IniRead Func _IniRead($sIniPath, $sIniSection, $sIniKey, $sIniDefault) Return _StrDecrypt(IniRead($sIniPath, $sIniSection, $sIniKey, _StrEncrypt($sIniDefault))) EndFunc ;==>_IniRead ; Encrypt a string using the default $enc_pass and $enc_level Func _StrEncrypt($sString) Return _StringEncrypt(1, $sString, $enc_pass, $enc_level) EndFunc ;==>_StrEncrypt ; Decrypt a string using the default $enc_pass and $enc_level Func _StrDecrypt($sString) Return _StringEncrypt(0, $sString, $enc_pass, $enc_level) EndFunc ;==>_StrDecrypt M23 mdiesel : Thank u for the idea ... i did like u said M23 : Thanks for the code ... I can only say that _StringEncrypt takes a LOT of time for encrypting 30kb of plain text Many thanks to both. Link to comment Share on other sites More sharing options...
Mat Posted April 18, 2009 Share Posted April 18, 2009 if you want it to be faster, use a lower encryption level, or find a different method of encryption...Possibly even a third party program that you can use... AutoIt Project Listing 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