Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to encrypt web.config

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to encrypt web.config, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

1. Open notepad and copy the following code to a new file.

The code is as follows:

Save my.aspx to your web directory and run the form to display "NT AUTHORITY\ NETWORK SERVICE". Success!

2. (the key step) run cmd and execute the following

Aspnet_regiis-pa "NetFrameworkConfigurationKey"NT AUTHORITY\ NETWORK SERVICE"

Description: register the default RSA key container for RsaProtectedConfigurationProvider

NetFrameworkConfigurationKey is the default provider for RsaProtectedConfigurationProvider. Success!

3. Now, you can encrypt web.config and run:

Encryption: aspnet_regiis-pe "connectionStrings"-app "/ Myweb"

Note: "connectionStrings" is the section to be encrypted, and "/ Myweb" is the web directory

Decryption: aspnet_regiis-pd "connectionStrings"-app "/ Myweb"

Success!

4. So you can call it in the program (no need to decrypt it,

):

...

String connstr= ConfigurationManager.ConnectionStrings ["myConnstr"] .ConnectionString.ToString ()

...

Similarly, you can also create your own RSA key container, as follows:

(1) create a "MyKeys" key container and run: aspnet_regiis-pc "MyKeys"-exp

(2) add the following to web.config:

The copy code is as follows:

Save.

(3) to grant the account access to the computer-level "MyKeys" RSA key container, run:

Aspnet_regiis-pa "MyKeys"NT AUTHORITY\ NETWORK SERVICE"

(4) now, you can encrypt web.config and run:

Encryption: aspnet_regiis-pe "connectionStrings"-app "/ Myweb"-prov "MyProvider"

Note: "connectionStrings" is the section to be encrypted, "/ Myweb" is the web directory, and "MyProvider" has its own key container.

Decryption: aspnet_regiis-pd "connectionStrings"-app "/ Myweb"-prov "MyProvider"

Thank you for reading this article carefully. I hope the article "how to encrypt web.config" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 222

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report