I am using AES encryption and generating a random salt, I am storing this random salt in the database.. Before I store the value to the database I want to append a string to it. I want this string to be placed in config file. How can I store a string in config file and How can I call in to append it with my salt.
Something like
<appSettings>
<add key="specialstring" value="value to append" />
</appSettings>
and access this by
ConfigurationSettings
ConfigurationManager.AppSettings["specialstring"]
and append
Also you can use WebConfigurationManager
in the same way instead of
ConfigurationSettings
ConfigurationManager
Set value in web-config file by below code snippet
<appSettings><add key="KeyForValue" value="ValueString" /></appSettings>
Get value in coding file by below code snippet
string strValuetoGet = ConfigurationManager.AppSettings["KeyForValue"]
put the string in the appSettings section of your web.config file, something like this:
<appSettings>
...
<add key="mySaltPrefix" value="your value..." />
...
</appSettings>
then read it from your C# code in this way:
var mySaltPrefix = System.Configuration.ConfigurationManager.AppSettings["mySaltPrefix"];
to run this code you should add a reference to System.Configuration to your C# project.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.