C code example for decrypting a password in a program

Source: Internet
Author: User

The question is raised

In the actual software project, often involves the processing of the password, such as user login password, database password, ftp password and so on. In order to increase the flexibility of software, these passwords are generally required to be placed in a configuration file. But the original password is easy to record, if the software intruder access, the consequences will be unthinkable. Therefore, we can not directly fill in the original password into the configuration file, but first encrypt the password, and then fill in the encrypted ciphertext into the configuration file, and so the program read the configuration before the decryption process.

The entire process is shown in 1.

Figure 1 Adding and decrypting the overall process

Sample program Flow

In order to demonstrate the entire decryption process, a demo program is designed, which executes flow 2.

Figure 2 Sample program Flow

Sample program code

Configuration file Example

The configuration file is named Config.ini, which is set to 3.

Figure 3 Configuration file contents

Program execution Results

1. Idecryptflag is 0 o'clock:

The execution results are shown in 4:

Figure 4 Execution result of Idecryptflag to 0 o'clock

To view the configuration file, the password value is ciphertext after encryption.

2. Idecryptflag is 1 o'clock:

The execution results are shown in 5:

Figure 5 Execution result of Idecryptflag to 1 o'clock

Viewing the configuration file, the password value goes through the process of "text-to-text-to-source".


C code example for decrypting a password in a program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.