Jump to content

How to lock .txt file


gahhon
 Share

Recommended Posts

Hi,

I have a program that is read data from the .txt file, since the .txt file is only readable, viewable and editable for the admin user.

But how could I lock it with password, or some other technique that can helps to achieve this?

Thanks for the advanced information.

Link to comment
Share on other sites

Well there is multiple possibilities here.  The simplest would be to place the .txt file into a directory (like windows\system32) only accessible by admin and give admin priv to the script (#RequireAdmin).

Link to comment
Share on other sites

You can encrypt it with a key.   the key is your password, and required to decrypt it. ..search in the helpfile for then crypt functions

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Hey hello, :) 

To learn crypt decrypt to everyone i got this script. 

 

Say us if you need help but if you read this slow you will figure out how to do i guess. 

#include <Crypt.au3>

Local Const $sUserKey = "CryptPassword" ; Declare a password string to decrypt/encrypt the data.
Local $sData = "..upon a time there was a language without any standardized cryptographic functions. That language is no more." ; Data that will be encrypted.

Local $bEncrypted = _Crypt_EncryptData($sData, $sUserKey, $CALG_RC4) ; Encrypt the data using the generic password string.

MsgBox(0, "Crypted data", "BinaryToString"&@CRLF&BinaryToString($bEncrypted))
MsgBox(0, "Crypted data", "Nothing"&@CRLF&$bEncrypted)
MsgBox(0, "Crypted data", "StringToBinary"&@CRLF&StringToBinary($bEncrypted))

$bEncrypted = _Crypt_DecryptData($bEncrypted, $sUserKey, $CALG_RC4) ; Decrypt the data using the generic password string. The return value is a binary string.
MsgBox(0, "Decrypted data", "BinaryToString"&@CRLF&BinaryToString($bEncrypted)) ; Convert the binary string using BinaryToString to display the initial data we encrypted.
MsgBox(0, "Decrypted data", "Nothing"&@CRLF&$bEncrypted)
MsgBox(0, "Decrypted data", "StringToBinary"&@CRLF&StringToBinary($bEncrypted))

Now you can combine that with anyscript. 

 

3 tips : 

- With crypted data in a file the file will be able to be open.

- With text file in Admin dir it will be able to be read but cannot be deleted. 

- With crypted data in admin dir : It wont be able to be delete but can be read but not understanable by peoples.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Hi.

Almost like mentioned above already: I guess, that your file is placed on some network share, as different users have to access it.

 

If the content is not secret, use NTFS or SHARE rights (or both) to grant write access to only those users, that shall be able to modify the TXT file's content.

 

To do so I'd like to recommend to use an existing group or to create a new one. Then all you need to do to is to add or remove the qualified users to / from this group.

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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

×
×
  • Create New...