掩码密码字符串 [英] mask password string

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

问题描述

我正在创建一个 C# windows 窗体应用程序,它使用 MSTSC 只需单击一下即可将我登录到我的服务器.我在纯文本代码中有我的管理员名称和密码,想知道有没有办法屏蔽/隐藏密码?我将我的代码存储在我的 Dropbox 中,并且希望它不可读.

I'm creating a C# windows forms app that logs me in to my servers with a single click using MSTSC. I have my admin name and password in the code in plain text and wondered is there a way to mask/hide the password? I store my code in my Dropbox and would prefer it wasn't readable.

    private void RunAsAdmin(string server)
    {
        Process rdcProcess = new Process();
        rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\cmdkey.exe");
        rdcProcess.StartInfo.Arguments = "/generic:TERMSRV/192.168.0.217 /user:" + "Administrator" + " /pass:" + "myPassword";
        rdcProcess.Start();

推荐答案

使用这个函数来encryptdecrypt密码.

Use this function to encrypt and decrypt the password.

 Public Function ConvertPassword(ByVal sPassword As String)
        Dim sTempChar As String
        Dim iCount As Integer

        For iCount = 1 To Len(sPassword)
            If Asc(Mid$(sPassword, iCount, 1)) < 128 Then
                sTempChar = CType(Asc(Mid$(sPassword, iCount, 1)) + 128, String)
            ElseIf Asc(Mid$(sPassword, iCount, 1)) > 128 Then
                sTempChar = CType(Asc(Mid$(sPassword, iCount, 1)) - 128, String)
            End If

            Mid$(sPassword, iCount, 1) = Chr(CType(sTempChar, Integer))
        Next iCount

        Return sPassword
    End Function

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

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