保护源$ C ​​$ C密码吗? [英] Securing a password in source code?

查看:131
本文介绍了保护源$ C ​​$ C密码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在code这是需要连接到SFTP服务器有一个密码。请告诉我模糊或隐藏在code的最佳方式?

I have a password in my code which is needed to connect to a sftp server. Whats the best way to "obfuscate" or hide it in the code?

感谢

推荐答案

不要储存您的密码在你的源$ C ​​$ C,将其存储在你心中的受保护的部分App.Config中(或Web.Config中)。

Don't store you password in your source code, store it in a protected section within you App.Config (or Web.Config).

请参阅的加密配置文件的部分使用受保护的配置的部分的微软文档

这的工作原理是利用加密,内置的Windows东西,锁定的MAC地址和其他各种东西无证加密密钥。

This works by encrypting the encryption keys using built-in Windows stuff, locked to the Mac address and various other undocumented things.

这甚至会工作,如果你正在使用多台服务器:

This will even work if you are using more than one server:

...如果你打算使用在多个服务器上,如Web场相同的加密的配置文件,只有RsaProtectedConfigurationProvider使您能够导出用于加密数据,并将其导入另一台服务器上的加密密钥。

... if you are planning to use the same encrypted configuration file on multiple servers, such as a Web farm, only the RsaProtectedConfigurationProvider enables you to export the encryption keys used to encrypt the data and import them on another server.

(不是寻找到你的IL迄今为止密码不是不可能,但很难)用这种方法,如果有人希望得到你的密码,他们就必须首先打破你的服务器上的Windows安全性。

Using this, if someone wanted to get your password, they would have to first break the Windows security on your server (not impossible, but harder than looking into your IL for the password by far).

这篇关于保护源$ C ​​$ C密码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆