So I have a connection string which is read from a basic text file. This string contains a password. Is there anyway to encrypt this text file so that anyone can't just open it up and read it. The program will still be able to read it.
Printable View
So I have a connection string which is read from a basic text file. This string contains a password. Is there anyway to encrypt this text file so that anyone can't just open it up and read it. The program will still be able to read it.
Search the forum for Encrypt Decrypt. There are loads of posts relating to file encryption and decryption.
Yes, it is possible. In order to encrypt and decrypt a file you will need to use the System.Security.Cryptography Namespace.
I don't have any code sample right now as I'm at work but I'm pretty sure you can find a lot by a simple google search, or maybe someone else will post some.
Basically what you will need to do is choose a cryptography Symmetric Algorithm use it encrypt and decrypt your file. Your application will need to know the password that was used to encrypt the file to be able to decrypt it.
here's a good example
are you aware of the basic concepts of the cryptography such as what are the features of symmetric key algorithms,assymetric key algorithm,etc etc
if not then i think there wont be anyone who will guide you from the very basics....i will suggest you to have a google search on this topic,decide whether you want to use symmetic or assymetric key algorithm according to your need,then have a go at that particular algorithm,try to implement it in your code and then post the particulars which will cause you problem...
Then only you will get some good guidance.....:)
:thumb:
Rijndael is a symmetric key algorithm.....keep it in mind before having a go at the above link
Does it need to be in a text file? Connections strings are generally stored in the config file, which supports encryption inherently. Follow the CodeBank link in my signature and check out my Protected Configuration thread for more info.