Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am trying to store confidential encrypted user information for my program on a single computer. I do not want the application to be copied on to another computer and be usable. So I was thinking about storing the information in the Registry but I read that that is a very unsafe location and is bad for more reasons then one. I started storing the information in the programs Settings.config file but I am not sure how to encrypt that information.. The only thing I have gotten to work so far is storing the information in a XML file and encrypting that which has worked but I want the information to be more hidden and more secured.
Any help on how and where to store some confidential information would be greatly appreciated! :)
Posted

Look for isolated storage: http://msdn.microsoft.com/en-us/library/3ak841sy%28v=VS.100%29.aspx[^]. In particular, read the section "Secure Access" to understand security implications.

If you want to encrypt the data, you should understand that the level of security depends on the strength of the encryption algorithm and, importantly, on how you store the key(s). You should consider what kind of exploit is more dangerous: ability to decrypt or modify encrypted data. It's likely that both aspects are equally important; in this case the power of public-key cryptography (http://en.wikipedia.org/wiki/Public-key_cryptography[^]) may appear redundant, so faster symmetric-key algorithms (http://en.wikipedia.org/wiki/Symmetric_key_algorithms[^]) would be more appropriate. Further considerations depend on the general security scenarios you want to devise.

In contrast, if you want to protect data exclusively used by only one user, you can devise a schema when a private key is known only to the user and not stored in the system (so no one of your site personnel could manipulate the users' data). In this case, you should use public-key cryptography.

Both types of encryption algorithms are well implemented in .NET. See:
Public-key cryptography (Asymmetric algorithms): http://msdn.microsoft.com/en-us/library/system.security.cryptography.asymmetricalgorithm.aspx[^];
Symmetric algorithms: http://msdn.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.aspx[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 8-Aug-11 18:30pm    
Very good answer, my 5
Sergey Alexandrovich Kryukov 8-Aug-11 21:57pm    
Thank you, Espen. Hope it will give OP enough options to design secure service.
--SA
Sergey Alexandrovich Kryukov 8-Aug-11 21:57pm    
OP commented:

Thank you both for your help! I now understand Encryption better and now need to focus on where to store settings and info. Where do you think is a good location to store something safely inside the registry? And is there any possible way to Encrypt the "Yourapp.Settings" file?
Thanks!
Sergey Alexandrovich Kryukov 8-Aug-11 22:03pm    
Do not store anything in the Registry, ever! Use either "special folder" System.Environment.GetFolderPath(Environment.SpecialFolder), or, for secure option, isolated storage.

I would not encrypt the application settings file, but you can encrypt separate values. All cryptography algorithms provide XML-friendly forms of encrypted data.

--SA
Always search MSDN first. The keyword is "Cryptography".
Here is ProtectedData Class that can be used in your case. And here is "How to: Use Data Protection".
 
Share this answer
 
Comments
Sergey Chepurin 9-Aug-11 3:37am    
Agree with SAKryukov, leave registry to the system. Though, i used it to store encrypted product key (and can not blame if anyone also will do it). You can place encrypted file in special or hidden folder, folder with access restrictions, etc. I would encrypt only sensible user information if you are afraid of leaks. Every such operation takes human brain's and processor's resources, and you should be sure what you are doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900