I'm programming an application in my company, and there is a file watcher:
fsw.NotifyFilter = (NotifyFilters.Security Or NotifyFilters.LastAccess Or NotifyFilters.LastWrite)
AddHandler fsw.Changed, New FileSystemEventHandler(AddressOf OnChanged)
AddHandler fsw.Created, AddressOf OnChanged
AddHandler fsw.Renamed, AddressOf OnRenamed
AddHandler fsw.Deleted, AddressOf OnChanged
But I want to protect some files from users by send it in skype, messanger oruploading it to any cloud.
Ex. I have an dgg file it open with dogland.exe, I want to make this .dgg extension to just with this app and encrypt and protect it from other programs to read this file.
What is the best way to protect this file? I'm using vb.net, 4.6.1
You're not going to be able to stop a user with admin rights on their machine from sending a file if they want to, so you're right that the answer is to make it useless elsewhere.
Before answering your question, I want to address two key points:
That said, the absolute simplest method is symmetric encryption, where your program uses the same key to both encrypt and decrypt. This is vulnerable to someone examining your code and retrieving the key, but it will stop most casual attempts.
To try it, put this in the main form:
And this goes in a helper module:
To implement the above code, just call the encrypt method on your data before writing it to your file:
And you invoke
Decrypt3DESto decrypt the data after you load it from your file:This is probably the simplest solution, but the word 'best' is relative in information security. You need to tailor your level of effort to the value of the information that you are trying to protect and the risk profile of having it exposed. You can do either too much or too little.
You could make this method stronger by not storing the encryption key locally but retrieving it at runtime from a server and clearing it from memory immediately after use. Or, you can encrypt the encryption password, so the actual password itself isn't visible in a disassembler and extra work is needed to get it. There are a thousand things you could do - hopefully this give you a starting point.
If you wanted to get more advanced, you could look into certificate-based signing and/or server-based controls that the user has no access to manipulate. It's all a question of how much the information is worth protecting.
DISCLAIMER: I don't warrant this to be fit for any particular purpose. This may or may not be suitable for your needs. Do your own research and ensure that any security mechanisms are fit for your purpose.