Share 4.19 lab password modifier c++

## 4.19 Công cụ sửa đổi mật khẩu phòng thí nghiệm C ++

** Hashtags: **

* #C ++
* #mật khẩu
* #bổ nghĩa
* #Lab
* #4.19

**Giới thiệu**

Trong phòng thí nghiệm này, bạn sẽ sửa đổi chương trình C ++ để thay đổi mật khẩu của người dùng.Chương trình trước tiên sẽ yêu cầu người dùng nhập mật khẩu hiện tại của họ.Nếu mật khẩu là chính xác, chương trình sẽ yêu cầu người dùng nhập mật khẩu mới của họ.Chương trình sau đó sẽ thay đổi mật khẩu của người dùng trong cơ sở dữ liệu.

**Bắt đầu**

Để bắt đầu, bạn sẽ cần phải sao chép kho lưu trữ sau:

`` `
Git Clone https://github.com/udacity/cppnd-capstone.git
`` `

Khi bạn đã nhân bản kho lưu trữ, hãy mở thư mục `4.19-l-password-modifier` trong trình chỉnh sửa mã của bạn.

**Chương trình**

Chương trình được đặt trong tệp `main.cpp`.Chương trình trước tiên yêu cầu người dùng nhập mật khẩu hiện tại của họ.Nếu mật khẩu là chính xác, chương trình sẽ yêu cầu người dùng nhập mật khẩu mới của họ.Chương trình sau đó sẽ thay đổi mật khẩu của người dùng trong cơ sở dữ liệu.

** Sửa đổi chương trình **

Để sửa đổi chương trình, bạn sẽ cần thực hiện các thay đổi sau:

1. Trong hàm `main ()`, thêm mã sau để kiểm tra xem mật khẩu hiện tại của người dùng có đúng không:

`` `
if (password_checker.check_password (current_password)) {
// Mật khẩu là chính xác.
} khác {
// Mật khẩu không đúng.
std :: cout << "Mật khẩu bạn đã nhập không chính xác. \ n";
trả lại 1;
}
`` `

2. Trong hàm `main ()`, thêm mã sau để thay đổi mật khẩu của người dùng trong cơ sở dữ liệu:

`` `
password_modifier.change_password (tên người dùng, new_password);
`` `

** Chạy chương trình **

Để chạy chương trình, hãy mở một cửa sổ thiết bị đầu cuối và điều hướng đến thư mục `4,19-l-password-modifier`.Sau đó, nhập lệnh sau:

`` `
./chủ yếu
`` `

Chương trình trước tiên sẽ yêu cầu bạn nhập mật khẩu hiện tại của bạn.Sau đó, chương trình sẽ yêu cầu bạn nhập mật khẩu mới của bạn.Chương trình sau đó sẽ thay đổi mật khẩu của bạn trong cơ sở dữ liệu.

**Phần kết luận**

Trong phòng thí nghiệm này, bạn đã học cách sửa đổi chương trình C ++ để thay đổi mật khẩu của người dùng.Bạn có thể sử dụng kiến thức này để tạo các chương trình của riêng bạn cho phép người dùng thay đổi mật khẩu của họ.
=======================================
## 4.19 Lab Password Modifier C++

**Hashtags:**

* #C++
* #Password
* #modifier
* #Lab
* #4.19

**Introduction**

In this lab, you will be modifying a C++ program to change a user's password. The program will first ask the user to enter their current password. If the password is correct, the program will then ask the user to enter their new password. The program will then change the user's password in the database.

**Getting Started**

To get started, you will need to clone the following repository:

```
git clone https://github.com/udacity/CppND-Capstone.git
```

Once you have cloned the repository, open the `4.19-lab-password-modifier` folder in your code editor.

**The Program**

The program is located in the `main.cpp` file. The program first asks the user to enter their current password. If the password is correct, the program will then ask the user to enter their new password. The program will then change the user's password in the database.

**Modifying the Program**

To modify the program, you will need to make the following changes:

1. In the `main()` function, add the following code to check if the user's current password is correct:

```
if (password_checker.check_password(current_password)) {
// The password is correct.
} else {
// The password is incorrect.
std::cout << "The password you entered is incorrect.\n";
return 1;
}
```

2. In the `main()` function, add the following code to change the user's password in the database:

```
password_modifier.change_password(username, new_password);
```

**Running the Program**

To run the program, open a terminal window and navigate to the `4.19-lab-password-modifier` folder. Then, type the following command:

```
./main
```

The program will first ask you to enter your current password. Then, the program will ask you to enter your new password. The program will then change your password in the database.

**Conclusion**

In this lab, you learned how to modify a C++ program to change a user's password. You can use this knowledge to create your own programs that allow users to change their passwords.
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top