Encrypt file with access to run
-
Dear all,
I encrypt my file & save it using .ini which connect to other software shortcut.
So, when I run my software shortcut, it will connect to .ini file & open my software with setting inside .ini file.
Is it possible to encrypt the file with access to run my text files ?
Actually my software can’t read the setting inside .ini file after encrypted. -
sorry, not 100% sure what you try to achieve.
What means software shortcut in your case?
And what do you mean by “open my software with setting inside .ini file”?Do you look for some general way to encrypt/decrypt text from within npp?
If so, yes, there is a plugin and using shortcut mapper would allow assigning
shortcuts to different functions.Or do you mean that you want to execute a 3rd party software from within npp and
before starting that software you want to read encrypted content from that ini, which then is forwarded as parameters to that 3rd party program? -
@Ekopalypse ,
Thanks for your comment, I wan to achieve your last comment " I want to execute a 3rd party software from within app and
before starting that software you want to read encrypted content from that ini, which then is forwarded as parameters to that 3rd party program? ". Hope you can help me please :-) :-). -
This highly depend on how this 3rd party app is working internally. Does this program accept command line arguments or does it assume that your ini file is at a certain place and reads the settings from their? Is this program available to others like me? What kind of information do you want to forward to that app?
Normally I would expect an workflow like this
- open your ini
- decrypt your ini
- save ini
- run external program
- wait until external program has finished
- encrypt ini
- save ini
- close ini
-
It is difficult to apply that workflow because so many user connect to the setting file.
I have Tekla Structures Program https://www.tekla.com/products/tekla-structures
When I right click on the shortcut, I modify the shortcut target to connect to “.ini” file :C:\TeklaStructures\2018\nt\bin\TeklaStructures.exe -i K:\MySetting.ini
Inside MySetting.ini file, there are some parameter for tekla setting, like default license for user :
rem set XS_DEFAULT_LICENSE=FULL
rem set XS_DEFAULT_LICENSE=CONSTRUCTION_MANAGEMENT
rem set XS_DEFAULT_LICENSE=PROJECT_VIEWER
rem set XS_DEFAULT_LICENSE=DRAFTER
set XS_DEFAULT_LICENSE=STEEL_DETAILING
rem set XS_DEFAULT_LICENSE=TeklaStructures_Primary
rem set XS_DEFAULT_LICENSE=EDUCATIONALI want to encrypt this file to protect the setting, but Tekla Software can read & apply the setting to all user.
Thanks
-
I see, is your goal to protect it against everyone using the software or
people who do have access to the server/pc but are not members of your company?Normally I would argue that the software itself should have this feature
because from your side, you cannot really protect it 100%.If the software reads, and I assume also writes, the ini in a clear text format,
then there is always a chance to get the info from the file
because you cannot encrypt the file as long as it is running,
otherwise changes, which have to be written to that ini,
would corrupt the file.There are workarounds like using ramdisks or partially encrypt content
from the file but none of them are really usable if more people are
having to use the exact procedure and do have access to that ini but
shouldn’t have. I’m afraid but I think that in such cases, notepad++
can’t be really the solution to your problem. -
We (presumably) know nothing about Tekla, as this isn’t a Tekla forum. However, it would surprise me if Tekla could read an encrypted
.ini
file.If it cannot, then Notepad++ really isn’t the right tool, because you’d need something that would store the file encrypted, but then unencrypt it before running TeklaStructures.exe, then re-encrypt it after your executable were run. That’s way beyond the scope of a Notepad++ editor forum; following the sequence that @Ekopalypse showed gives you a general idea of what to do.
If Tekla can read encrypted
.ini
, great: then Notepad++ could help you automate unencrypting the file so you can edit it, then re-encrypting when you’re ready to save. Basically, you would have two scripts in Notepad++ (where those scripts might NppExec scripts, or PythonScript code), which will break up the task into the two steps: after opening the file, run the “unencrypt” script, which would pass the.ini
source code through the external decryption algorithm; after editing, then run the “encrypt” script, and then save the encrypted.ini
when done. Assuming you know thec:\path\to\TeklaCompatibleEncryption\encrypt.exe
and...\decrypt.exe
, those should be fairly easy scripts to write.I sometimes use GPG to encrypt or decrypt files inside Notepad++, using the following NppExec scripts:
GpgDecrypt
cls cmd.exe /c exit %RANDOM% // cannot access $(SYS.RANDOM) directly through NppExec, but can tell cmd.exe to return it as a value set tempfile = $(SYS.TEMP)\NppGpgFile_$(EXITCODE).tmp // create random tempfile name set ascfile = $(SYS.TEMP)\NppGpgFile_$(EXITCODE).asc // create associated ascfile name sci_sendmsg SCI_SELECTALL // select all sel_saveto $(ascfile) :a // save selection to the ascfile (use :a to save as ansi, to prevent unicode prefix ÿþ getting embedded) gpg.exe --output "$(tempfile)" --decrypt "$(ascfile)" // decrypt sel_loadfrom $(tempfile) // replace selection with results sci_sendmsg SCI_DOCUMENTSTART // deselect rm -rf "$(tempfile)" "$(ascfile)" // cleanup temp files npp_save
GpgEncrypt
cls cmd.exe /c exit %RANDOM% // cannot access $(SYS.RANDOM) directly through NppExec, but can tell cmd.exe to return it as a value set tempfile = $(SYS.TEMP)\NppGpgFile_$(EXITCODE).tmp // create random tempfile name set ascfile = $(SYS.TEMP)\NppGpgFile_$(EXITCODE).asc // create associated ascfile name sci_sendmsg SCI_SELECTALL // select all sel_saveto $(tempfile) :a // save selection to the tempfile (use :a to save as ansi, to prevent unicode prefix ÿþ getting embedded) INPUTBOX "Recipients (use -r between multiple): " : peter.jones@maximintegrated.com -r petercj@pryrt.com // get the recipients gpg.exe --output "$(ascfile)" -ase -r $(INPUT) "$(tempfile)" // armor+sign+encrypt to recipient(s) sel_loadfrom $(ascfile) // replace selection with results sci_sendmsg SCI_DOCUMENTSTART // deselect //rm -rf "$(tempfile)" "$(ascfile)" // cleanup temp files npp_save
-
Thanks to @Ekopalypse & @PeterJones for your advise
Actally Tekla can’t read encrypt .ini file, I will try to find another solution.Thanks all