views:

513

answers:

5

Hi..

i am generating *.reg file using code which will have some important data. and user will save this into registry.

upon application launch i am getting the values from registry and performing some validation..

but the problem is that in registry and in *.reg file the information are stored in plain text.

how can i create encrypted *.reg file first.

then in application start. how to decrypt the value(encrypted) from registry..

i read some articles. but they are related to encryption/decryption of file. here i am working with "*.reg" file and Registry itself

+1  A: 

If your program is the only one that is reading the values from the registry you can save them encrypted and decrypt them on every use. This way the exported .reg file is going to contain encrypted data too.

If there are other programs using the data you must ensure they can access and understand the information they need.

devdimi
+2  A: 

What you want to do is to encrypt the values of the registry keys that you are created. You can do that at the time of creating the reg file. Here's a good howto with code examples of encryption/decryption in general:

http://www.dotnetthis.com/Articles/Crypto.htm

Use that to store the encrypted values in the registry. Retrieve the registry values, and decrypt them using the methods from the above article.

David Hedlund
A: 

What's the point? Anyone can just use a tool like Regmon to find out what values you set anyway.

You should instead just encrypt the values and decrypt them when your application reads them (that is assuming your app the only one accessing that data). Keep in mind, though, that you'd have to store the decryption key somewhere in your executable which opens up a whole other can of worms.

n3rd
A: 

You wont be able to transparently encrypt the registry.

I would look at either public/private key or symmetric key encryption methods.

Here is a quick project to use RSA: http://www.codeproject.com/KB/security/RSACryptoPad.aspx

Storing your keys in a resource is probably the best way to protect the contents, but be warned: If you store both the Key and the Cyphertext on the same system (eg, in your program and in the registry) there is no way to fully prevent the owner of the system from reading the Plaintext.

John Gietzen
A: 

Sorry Mohsan, that's the wrong way. d. showed the right way.

Just imagine if you encrypt a .reg file. What should happen afterwards?? You'll like to import it into the registry, but before you can you have to decrypt it and so just plain text comes into registry which can be read be everyone.

So don't encrypt your key or value names. Encrypt the content of your values within the registry. So your program can read it in, decrypt it and work with it. Here is an example:

[HKLM\Key\SubKey\SubSubKey\etc]
@=""
"Password"="KALSDJLSIWNKLDNISNDLKWDNLAW"

So you program opens the key, reads the value and computes the decrypt algorithm on that value, resolving it to: 'My Secret Password'

Oliver