Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

HIDING CONTENTS OF TEXT FILES FROM PRYING EYES; USING APPLICATION.EXECUTABLEPATH

OK, here I am again. There are two questions in one, both interrelated.
1. I have a text file containing important information. I want the user to be able to read the content of this text file only through a textbox when the application is running. I have tried changing the file extensions from .txt to .bat or .dat, etc. Although it appears to work, the contents become easily readable when I changed the file extension to .doc, .txt, or .rtf. How can I make the text unreadable except through the application? Or, is it possible to compile the textfile with the application?
I have tried encryption, but I found the process rather cumbersome. I don't want to encrypt and decrypt ad infinitum. I don't want to use a database either; a textfile is just fine for my purpose.

2. I want to use the same text file to populate a textbox in a form. The text file is saved in the same directory as my project. Since I do not know where the users of my application will install it, I did not want to hardcode the path, so I used Application.ExecutablePath. The application gave an error: can't find the file. If I used "c:\\mytextfile.txt" it works fine

Thanks everyone, for your help.

Dave
0
innovator2
Asked:
innovator2
  • 2
  • 2
1 Solution
 
BillFoustCommented:
What does the text file contain? Is the information constant or dynamic? If it is constant, then I would compile it into your applications or possibly compile it into a seperate library.

If the contents are dynamic you only have two choices, Obfuscation or Encryption. Obfuscation is "light" encryption which focuses on making the text not immediately obvious or hidden in a way that the user cannot easily stumble upon it. Why not use the registry to store the text? If its small that alone is probably good enough to "hide" it. You can also do some simple "encryption" on it such as modifying the value of each byte in the file by adding 5. That way all 'a's become 'e' etc. That should be enough to make any casual user not want to try to read it. You can make the filename non-obvious as well. Don't use an extension or use a non-standard one. "myfile" or "myfile.zzz".

As for your file problems, try referencing the file from ".". "." is a valid DOS directory meaning the current directory. ".\myfile.txt" for example.

Bill
0
 
innovator2Author Commented:
Thanks, Bill
To the first question, the information is static. However, how do I compile it into the application? The IDE creates a bin folder, which contains my executable file. How do I instruct the IDE to add the textfile to the executable?

Dave
0
 
BillFoustCommented:
I'm not sure. All of my work with C# has not been UI stuff. In C++ you would create a StringTable resource and add the text as an entry into the StringTable. Then the code to populate the text box would have another version taking the resource ID of the string.  The process should be pretty similiar in C#, though I cannot provide specifics. I'll try to find out next week and let you know.
Bill
0
 
innovator2Author Commented:
Will be on the lookout.
Thanks,

Dave
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now