开发者

how to Decrypt Application settings before binding?

I am using Application settings in my c# project to save gmail username and password. Before saving the settings I am encrypting the plain text password. When I am restarting the app retrieving them is of course without any problem but the retrieved password is encrypted. What I want is to decrypt it back before binding back to the textbox The code generated by the designer is something like the follows:

this.tb_Gmail_Password.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::MyApp.Properties.Settings.Default, "GmailPassword", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
开发者_C百科

I don’t know if I am able to put my question properly. Plz feel free to kick me if I sound like speaking alien language. I will give more description as per your suggestion…

Regards, N10i.

--edit--

while saving the configuration i am using a custom function to encrypt the password i.e.

Properties.Settings.Default.GmailPassword = MyApp.EncPass(tb_Gmail_Password.Text);

can i use something similar like

this.tb_Gmail_Password.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::MyApp.Properties.Settings.Default, MyApp.DecPass("GmailPassword"), true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));

i.e.

MyApp.DecPass("GmailPassword")


You encrypt the configuration using DPAPI DpapiProtectedConfigurationProvider, and you decrypt it using the same at application start up, see Encrypting Configuration Information Using Protected Configuration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜