C# 隐藏重要数据

C# 隐藏重要数据,c#,C#,只想问一下,在.Net桌面应用程序中隐藏敏感数据(ftp帐户、数据库连接字符串等)的最佳方法是什么。。有什么建议吗……) 我意识到将数据放入应用程序中,并考虑到如果应用程序将被除臭或反编译,隐藏的数据将被公开 我尝试使用应用程序设置 Properties.Settings.Default.MyConnectionString = theConString; 但反编译时仍然可以看到数据 请提供任何建议。您可以对app.config文件的全部或部分进行加密。这对于保护数据库连接字符串尤其常见 这里

只想问一下,在.Net桌面应用程序中隐藏敏感数据(ftp帐户、数据库连接字符串等)的最佳方法是什么。。有什么建议吗……)

我意识到将数据放入应用程序中,并考虑到如果应用程序将被除臭或反编译,隐藏的数据将被公开

我尝试使用应用程序设置

Properties.Settings.Default.MyConnectionString = theConString;
但反编译时仍然可以看到数据


请提供任何建议。

您可以对app.config文件的全部或部分进行加密。这对于保护数据库连接字符串尤其常见

这里有一个关于如何解决这个问题的例子。简而言之,下面是加密app.config中连接字符串部分的代码:

static void ToggleConfigEncryption(string exeConfigName)
{
    // Takes the executable file name without the
    // .config extension.
    try
    {
        // Open the configuration file and retrieve 
        // the connectionStrings section.
        Configuration config = ConfigurationManager.
            OpenExeConfiguration(exeConfigName);

        ConnectionStringsSection section =
            config.GetSection("connectionStrings")
            as ConnectionStringsSection;

        if (section.SectionInformation.IsProtected)
        {
            // Remove encryption.
            section.SectionInformation.UnprotectSection();
        }
        else
        {
            // Encrypt the section.
            section.SectionInformation.ProtectSection(
                "DataProtectionConfigurationProvider");
        }
        // Save the current configuration.
        config.Save();

        Console.WriteLine("Protected={0}",
            section.SectionInformation.IsProtected);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}

你不能真的那样做。如果应用程序可以访问数据,那么运行它的任何人都可以。如果你想隐藏一些敏感数据,根本不要把它们放在应用程序中。@svick的观点很重要——你在保护谁?如果您试图阻止应用程序的最终用户看到它们,那么可能根本无法将它们存储在应用程序中。也就是说,有一些方法可以安全地存储它们,以防止最终用户PC上未经授权的用户(比如病毒)读取它们。