AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Password to open AHK ini file

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Wolfer



Joined: 08 Nov 2005
Posts: 14
Location: Chicago, IL

PostPosted: Wed Apr 23, 2008 5:33 pm    Post subject: Password to open AHK ini file Reply with quote

I apologize for my limitations in advance...

Is it possible to add a script to my AHK ini file that will encrypt the .ini file when I close it, and then ask for a password when I open it, and then decrypt and load the ini file? Essentially, a password + encryption lock to hide everything in the script file, but still keep the .ahk extension so it will try to load when clicked on?

I am trying to avoid having to do a separate encryption/decryption every time I open AHK. I would need this in certain selected files, not every AHK file.

[VxE]'s Encryption Function is excellent, as are others, but I'm trying to find a shortcut. I am trying to promote AHK as a timesaver in my physicians' group, but a major concern is security of passwords. As it is, I'm by far the most "techie" person in the group, and even I have some difficulty negotiating some of the encryption utilities. What's needed is super simplicity: click on AHK.exe, enter password in box, file decrypts and loads. Close AHK => file encrypts and closes and is unreadable off the hard drive. Any takers?

If this has already been done, kindly point me to the post. And thanks to everyone for this great forum!
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Sat Oct 25, 2008 12:23 pm    Post subject: Reply with quote

You can save your scripts in a small TrueCrypt container.
_________________

Back to top
View user's profile Send private message Visit poster's website
[VxE]



Joined: 07 Oct 2006
Posts: 1494

PostPosted: Sat Oct 25, 2008 6:58 pm    Post subject: Reply with quote

Here's a short illustration of one way to go about having a script keep its ini file encrypted when not in use. It's not a working example, but it should give an idea or two. Another method would be to keep the key values encrypted and only decrypt them when they are being used.

Code:
OnExit, OnExitSubroutine

MyINIFile = %A_MyDocuments%\TestInfo.ini

; A snippet to read from an encrypted ini file
   InputBox, mypassword, What's my password !
   
   FileRead, InFile, %MyINIFile% ; read an encrypted ini file
   FileMove, %MyINIFile%, %MyINIFile%.tmp, 1 ; move the original out of the way
   FileAppend, % Decrypt(mypassword, InFile), %MyINIFile% ; write the decrypted file
   InFile := ""
   IniRead, Version, %MyINIFile%, The Top, Version, Error
   ; ... whatever other inireads you need ...
   FileMove, %MyINIFile%.tmp, %MyINIFile%, 1
   If Version = Error ; the file failed to decrypt if the key wasn't read
      msgbox Wrong Password !

OnExitSubroutine:
IfExist, %MyINIFile%.tmp
   FileMove, %MyINIFile%.tmp, %MyINIFile%, 1
Exitapp

; Example ini file:
; [The Top]
; Version=1.234.567
; [Data]
; Data1=Sir Lancelot
; Data2=To seek the grail
; Data3=Blue
; ...
/*
; To encrypt an ini file, try the following steps
; after all the keys have been added to the file
OnExitSubroutine:
FileRead, InFile, %MyINIFile%
FileAppend, % Encrypt(mypassword, InFile), %MyINIFile%.tmp
FileMove, %MyINIFile%.tmp, %MyINIFile%, 1
InFile := ""
Exitapp

_________________
My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group