在MSBuild文件中加密密码 [英] Encrypting password in a MSBuild file

查看:121
本文介绍了在MSBuild文件中加密密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用以下代码对我提供的密码进行加密:

I want to encrypt the password I am supplying in the following code:

<Target Name="Default">
    <!-- Install a service on a Remote Machine -->
    <MSBuild.ExtensionPack.Computer.WindowsService 
        TaskAction="Install" 
        ServiceName="__TestService1" 
        User="$(User)" 
        Password="$(password)"
        ServicePath="c:\WINDOWS\system32\taskmgr.exe" 
        RemoteUser="$(RemoteUser)" 
        RemoteUserPassword="$(RemoteUserPassword)" 
        MachineName="$(RemoteMachine)" />
</Target>

我不想对密码进行硬编码.如何加密?请提供您的建议.我用谷歌搜索,但找不到适合我的解决方案.

I dont want to hardcode the password. How can I encrypt it? Please provide your suggestion. I googled but could not find a solution which will work for me.

谢谢.

推荐答案

有很多方法可以做到这一点.我只描述两个最简单的方法:

There are many ways to do this. I describe just two simplest:

您是否考虑过使用NTFS加密文件系统的功能?

将密码以纯文本格式存储在文件中,并将文件标记为加密. 然后,只有用户创建的文件(默认情况下)才可以访问文件(如果您更偏执,可以通过为给定密码文件正确设置ACL来限制访问). 然后,您可以通过

Store password in a file as plaintext and mark file as encrypted. Then only user created file (by default) has an access to file (if you are more paranoid you can restrict access by proper setting ACL for given password file). Then you can easily read password by

<ReadLinesFromFile File="$(PasswordFile)" >
  <Output TaskParameter="Lines" ItemName="Password"/>
</ReadLinesFromFile>

其他可能性是将密码存储在注册表中(HKLM或HKCU),设置对选定用户的键权限. 您可以轻松地读取注册表值

Other possibility is to store password in registry (HKLM, or HKCU), set up permission to selected user on a key. You can easily read registry values

为了防止直接从ntuser.dat(注册表存储区)读取密码,您可以通过内联任务 http://msdn .microsoft.com/en-us/library/ff649224.aspx )

In order to prevent directly read password from ntuser.dat (registry storage – you can encrypt password by inline task for example this way http://msdn.microsoft.com/en-us/library/ff649224.aspx)

这篇关于在MSBuild文件中加密密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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