In my application I need to read an encrypted file that is distributed with the app. I also need to connect to a download service using a password. My conundrum is where to store the passwords for these resources? In other languages, such as C++, I would just have stored them in the code. However, as there are tools that can disassemble C#, such as JetBrains DotPeek, that is not secure.
Below are the solutions I have thought of so far, but I don't think any of them are secure:
- Store the passwords in the code: No good because C# can be disassembled.
- Store the passwords in an encrypted external resource: No good, because then you need to store the password for that!
- Ask the user for the password on first use (which they have been told by other means): No good, I think, because don't you still need to store it for subsequent use?
- Store them in a C++ dll: No good, because what is to stop anyone else calling the function in that dll?
- Hide and encrypt the passwords in the code: For example, don't call it password and use multiple levels of encrypting it. This would make it difficult for someone who was just text searching the code, but wouldn't stop someone prepared to debug the program to find out how the resources were accessed. No good.
- Obfuscate the code base to prevent disassembly: Possibly this might work. Is it secure? Does anyone do it?
What is the normal solution to this quite typical problem?