Jump to content

How do I encrypt / decrypt an ini file?


Recommended Posts

How do I encrypt / decrypt an ini file but still be able to add things to it later? It doesn't need to be elaborate but I don't want anyone in my ini file figuring out how the data flows and making changes.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

How do I encrypt / decrypt an ini file but still be able to add things to it later? It doesn't need to be elaborate but I don't want anyone in my ini file figuring out how the data flows and making changes.

See _StringEncrypt()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

How do I encrypt / decrypt an ini file but still be able to add things to it later? It doesn't need to be elaborate but I don't want anyone in my ini file figuring out how the data flows and making changes.

These functions should do it

FileRead, FileWrite and _StringEncrypt

Good Luck :)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

These functions should do it

FileRead, FileWrite and _StringEncrypt

Good Luck :)

I don't think it even needs the FileWrite() and FileRead() Just encrypt/decrypt the key and the value. Probably doesn't even need the key encryted, just the value.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

_StringEncrypt() ? Has someone already made a script for this that I can see? I have an ini file that has data in it now. How can I encrypt it and still have autoit read the data? I also need to add things to the ini file later or I need an interface that will show me the ini file contents unencrypted and then allow me to change them and re-encrypt them.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

OK I found an example but I am having a problem visualizing the process. I have found a program that will encrypt and decrypt a string of characters which shows me some in use examples of how _StringEncrypt() is used. I can use this program to make my ini file but I am thinking that I need to make a temp .ini file to access the data for my program. If my current ini file is called barcodes.ini and it looks like:

[whatever]

123=data1

12345=dataset2

234511=whateverdata1

and I encrypt it I get just one long string of encrypted characters. How can I take this string of characters from within the program and temporarily create a file that can be accessed while the program is running and have it store the decrypted data in that temp file and after the script exits to delete the data within the temp file?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

OK I found an example but I am having a problem visualizing the process. I have found a program that will encrypt and decrypt a string of characters which shows me some in use examples of how _StringEncrypt() is used. I can use this program to make my ini file but I am thinking that I need to make a temp .ini file to access the data for my program. If my current ini file is called barcodes.ini and it looks like:

[whatever]

123=data1

12345=dataset2

234511=whateverdata1

and I encrypt it I get just one long string of encrypted characters. How can I take this string of characters from within the program and temporarily create a file that can be accessed while the program is running and have it store the decrypted data in that temp file and after the script exits to delete the data within the temp file?

Try

IniWrite($Ini, "Whatever","12345", _StringEncrypt here)

IniRead(Ini, "Wharever", "12345, Decrypt it here, "")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I don't think it even needs the FileWrite() and FileRead() Just encrypt/decrypt the key and the value. Probably doesn't even need the key encryted, just the value.

I was just thinking that encrypting the whole file would be more secure since then the user don't even have to know that it's a ini file we're talking about.

:)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

I was just thinking that encrypting the whole file would be more secure since then the user don't even have to know that it's a ini file we're talking about.

:)

True. But becuase he will be making calls to the INI file that method could become a bit of a hassle. He could save the Ini File encryted as data.dat and embed it in the exe. But then he would have to FileInstall it someplace, decrypt it and then write it back as whatever.ini. Or if the Ini is going to be written to, it becomes even worse. He would have to copy the encrypted Ini file someplace, decrypt it and then write it back. When the app closes he will have to encrypt it again and then overwrite the old encrypted file and then move that back to where it started. Easier to just encrypt the values I think.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...