更改visual studio 2017 C#.NET framework 4的密码表单代码 [英] Change password form code for visual studio 2017 C# .NET framework 4

查看:198
本文介绍了更改visual studio 2017 C#.NET framework 4的密码表单代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am using Visual Studio 2017 C# .NET Framework 4

I have two forms

My first form has the code below that works. Enter password and click OK


//manually define password because we are not using any database


            string Password = "password";

            if (Password == textBox1.Text)
            {

                
            }
            else
            {
                

MessageBox.Show("You have entered an incorrect password, Please re-enter your password again!");


OK    Cancel


My second form has this
Does anyone have the code to make this work so the user can change their password?


Enter your current password

Enter your new password

Enter your new password again


OK    Cancel





我尝试过:



我能够创建我的第一个表单和输入密码的代码并单击确定但我无法弄清楚如何创建代码以便用户可以更改其密码。



What I have tried:

I was able to create my first form and code for Enter password and click OK but I can not figure out how to create code so the user can change their password.

推荐答案

您无法更改密码,因为您使用的是单个固定密码:

You can't change the password because you are using a single, fixed password:
string Password = "password";

你不能改变它,因为它是你申请的一部分。



为了开始写一个更改密码表格,你首先需要开始将用户及其密码存储在应用程序之外的某个位置 - 文本或二进制文件,XML,JSON,等等 - 或者存储在数据库中。在你确切地决定如何做到这一点之前,你甚至不能开始写一个更改密码表单,因为你不知道它将在何处或如何存储!



并帮自己一个忙:永远不要以明文形式存储密码 - 这是一个主要的安全风险。有关如何在此处执行此操作的信息:密码存储:如何做到这一点。 [ ^ ]但目前对你来说可能有点太高级了。

And you can't change that because it is part of your application.

In order to start writing a "change password" form, you first need to start storing users and their passwords somewhere outside your app - a text or binary file, XML, JSON, whatever - or in a database. Until you have decided exactly how you are going to do that, you can't even start to write a "change password" form because you have no idea where or how it is going to be stored!

And do yourself a favour: Never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^] but it may be a little too advanced for you at the moment.


这篇关于更改visual studio 2017 C#.NET framework 4的密码表单代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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