Disclosure of Invention
The embodiment of the invention provides a method and a device for generating an ini file, computer equipment and a medium, which are used for improving the safety of the ini file and protecting the safety of configuration information.
In a first aspect, an embodiment of the present invention provides a method for generating an ini file, where the method for generating an ini file includes:
determining the ini file configuration parameter information of the current flash ini file and the timestamp for configuring the ini file;
and determining ini file authentication information corresponding to the current flash ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file, and generating a target ini file containing the ini file authentication information.
Further, the ini file configuration parameter information comprises ECU version authentication information, variable name authentication information and variable number authentication information;
determining the ini file authentication information corresponding to the current flashing ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file comprises the following steps:
and determining the ini file authentication information corresponding to the current flash ini file according to the ECU version authentication information, the variable name authentication information, the variable number authentication information and the timestamp of the configuration ini file.
Further, the ini file authentication information comprises 10 authentication bytes;
the ECU version authentication information comprises 1 authentication byte, the variable name authentication information comprises 1 authentication byte, the variable number authentication information comprises 1 authentication byte, and the time stamp of the configuration ini file comprises 7 authentication bytes.
Further, the ECU version authentication information, the variable name authentication information, the variable number authentication information, and the time stamp of the configuration ini file are configured with a 16-ary number.
Further, determining a timestamp of the configuration ini file of the current writing ini file comprises:
and determining the legal use starting time and the legal use ending time of the current flash ini file, and determining the time stamp of the configuration ini file according to the legal use starting time and the legal use ending time.
Further, the method for generating the ini file further comprises the following steps:
acquiring the current use time of an ini file to be refreshed, and legal use starting time and legal use ending time corresponding to the ini file to be refreshed;
if the current use time is between the legal use starting time and the legal use ending time, the ini file to be rewritten is considered to pass the ini file authentication; and if the current use time is not between the legal use starting time and the legal use ending time, stopping the flashing process of the ini file to be flashed.
Further, the method for generating the ini file further comprises the following steps:
and storing the target ini file into a memory.
In a second aspect, an embodiment of the present invention further provides a device for generating an ini file, where the device for generating an ini file includes:
the information generating module is used for determining the ini file configuration parameter information of the current flash ini file and the timestamp for configuring the ini file;
and the file generation module is used for determining the ini file authentication information corresponding to the current flash ini file according to the ini file configuration parameter information and the timestamp of the configuration ini file, and generating a target ini file containing the ini file authentication information.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
a storage device for storing a plurality of programs,
when at least one of the programs is executed by the one or more processors, the one or more processors are enabled to implement the method for generating the ini file provided by the embodiment of the first aspect of the present invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for generating an ini file provided in the embodiment of the first aspect of the present invention.
According to the technical scheme of the embodiment of the invention, the configuration parameter information of the ini file of the current brushing ini file and the timestamp of the configuration ini file are determined; and determining ini file authentication information corresponding to the current flash ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file, and generating a target ini file containing the ini file authentication information. The problem that the system information and data are easily tampered due to lack of effective management on the ini file at the present stage, and data safety of a client during generating and using the ini file cannot be guaranteed is solved, so that the safety of the ini file is improved, and the safety of configuration information is protected.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention are described in further detail below with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention.
It should be further noted that, for the convenience of description, only some but not all of the relevant aspects of the present invention are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
When an ECU (Electronic Control Unit) writes a variable in a flash, the ini file format used is generally as follows:
| start byte | Field(s) | Data type | Description and claims |
| 0 | ECU software version | STRING | ASCII, max 20Bytes |
| 20 | Variable information | WORD | Key, value |
The ini file is easy to manufacture and crack, and further tampering of program system information and data is caused. In order to solve the existing technical problems, a method, a device, computer equipment and a medium for generating an ini file are provided, so that the safety of the ini file is improved, and the safety of configuration information is protected.
Example one
Fig. 1 is a flowchart of a method for generating an ini file according to an embodiment of the present invention, where the embodiment is applicable to a case where encryption and authentication of the ini file are effectively managed, the method for generating the ini file may be executed by a device for generating the ini file, and the device for generating the ini file may be implemented in a form of software and/or hardware. The method for generating the ini file specifically comprises the following steps:
s110, determining the ini file configuration parameter information of the current flash ini file and the timestamp for configuring the ini file.
The ini file configuration parameter information comprises ECU version authentication information, variable name authentication information and variable number authentication information.
Specifically, determining the ini file authentication information corresponding to the current flashing ini file according to the ini file configuration parameter information and the timestamp of the configuration ini file as follows: and determining the ini file authentication information corresponding to the current flash ini file according to the ECU version authentication information, the variable name authentication information, the variable number authentication information and the timestamp of the configuration ini file.
On the basis, the ECU version authentication information, the variable name authentication information, the variable number authentication information, and the time stamp of the configuration ini file are configured with a 16-ary number.
In this embodiment, the special characters are removed from the ECU version information of the current flash ini file, the rest is converted into 16-system numbers, and after all the characters are added and summed, only the 16-system number with the lowest two bits is reserved as the ECU version authentication information. The ECU version information may be configured and generated by the ECU itself, or preset in the program system by those skilled in the art, which is not limited in this embodiment.
All variables of the current writing ini file are obtained, characters corresponding to the initial letters of all the variable names are converted into 16-system numbers, and after the 16-system numbers are added and summed, only the 16-system numbers with the lowest two bits are reserved and used as variable name authentication information.
On the basis, the number of all variables of the current writing ini file is obtained, the variable number is converted into a 16-system number, and only the 16-system number with the lowest two bits is reserved and used as variable number authentication information. The number of variables of the current flash ini file is determined by the ini file, and the number of the variables is not explained too much in the embodiment, so that the specific number of the readable variables is used as the standard.
Further, determining a timestamp of the configuration ini file of the current writing ini file comprises: and determining the legal use starting time and the legal use ending time of the current flash ini file, and determining the time stamp of the configuration ini file according to the legal use starting time and the legal use ending time.
The time stamp for configuring the ini file specifies the legal use time of the ini file, and the legal use time of the ini file comprises legal use starting time and legal use ending time.
In this embodiment, the legal use start time and the legal use end time of the current flash ini file are taken as a numerical value, and are converted into a 16-system number to generate the time stamp of the configuration ini file.
In one embodiment, the ini file authentication information comprises 10 authentication bytes; the ECU version authentication information comprises 1 authentication byte, the variable name authentication information comprises 1 authentication byte, the variable number authentication information comprises 1 authentication byte, and the time stamp of the configuration ini file comprises 7 authentication bytes.
S120, determining ini file authentication information corresponding to the current flash ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file, and generating a target ini file containing the ini file authentication information.
It can be understood that the ECU version authentication information, the variable name authentication information, the variable number authentication information, and the time stamp of the configuration ini file collectively form the ini file authentication information corresponding to the current flash ini file, so that the ini file is encrypted and is safer.
When the ini file is generated, the ini file authentication information of the current brushing ini file is added to obtain the target ini file containing the ini file authentication information, so that the brushing data and content of the ini file are effectively prevented from being maliciously tampered by a client, and the information safety of a program system and a terminal is guaranteed.
On the basis of the above embodiment, the method for generating an ini file further includes: acquiring the current use time of an ini file to be refreshed, and legal use starting time and legal use ending time corresponding to the ini file to be refreshed; if the current use time is between the legal use starting time and the legal use ending time, the ini file to be rewritten is considered to pass the ini file authentication; and if the current use time is not between the legal use starting time and the legal use ending time, stopping the flashing process of the ini file to be flashed.
On the basis, if the current use time of the ini file to be refreshed is determined before the ini file to be refreshed is read, the timestamp of the configuration ini file in the ini file authentication information corresponding to the ini file to be refreshed is obtained through the ini file authentication information corresponding to the ini file to be refreshed, and the legal use starting time and the legal use ending time corresponding to the ini file to be refreshed are obtained.
If the current use time is between the legal use starting time and the legal use ending time, the ini file to be rewritten is considered to pass the ini file authentication, namely the ini file to be rewritten is in a legal time period; if the current use time is not between the legal use starting time and the legal use ending time, the ini file authentication cannot be passed, namely the ini file to be rewritten is not in the legal time period, the rewriting process of the ini file to be rewritten is stopped, so that the legal use of the ini file is ensured, and the safety of the configuration information is protected.
In an embodiment, the method for generating an ini file further includes: and storing the target ini file into a memory.
It can be understood that the target ini file containing the ini file authentication information is stored in a memory of the program system. When the generation information and the legal use time of the ini file to be refreshed are required to be inquired, the ini file containing the ini file authentication information and stored in the memory of the program system can be inquired, the generation information of the ini file and the corresponding ini file authentication information content can be traced back through the ini file authentication information of the ini file to be refreshed, the storage history of the ini file can be conveniently inquired, and the safety of the ini file is improved.
According to the technical scheme of the embodiment of the invention, the configuration parameter information of the ini file of the current brushing ini file and the timestamp of the configuration ini file are determined; and determining ini file authentication information corresponding to the current flash ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file, and generating a target ini file containing the ini file authentication information. The problem that the system information and data are easily tampered due to lack of effective management on the ini file at the present stage, and data safety of a client during generating and using the ini file cannot be guaranteed is solved, so that the safety of the ini file is improved, and the safety of configuration information is protected.
Example two
Fig. 2 is a flowchart of a method for generating an ini file according to a second embodiment of the present invention, which is optimized based on the second embodiment.
Correspondingly, the method of the embodiment specifically includes:
s210, determining the ECU version authentication information, the variable name authentication information and the variable number authentication information of the current flash ini file.
In one embodiment, the ECU version authentication information includes 1 authentication byte, taking the ECU version number WISE63-P920-V102 as an example, removing special characters, taking the ECU version number WISE63P920V102 as the example, adding and summing all characters to obtain 61B, and keeping only the 16-digit number of the lowest two bits, that is, the length of the last two bits is 1B, and 1B is used as the ECU version authentication information of 1 authentication byte.
The variable name authentication information comprises 1 authentication byte, and assuming that the ini file shares three variables, namely ACComp _ TiTrqDes _ C, ACComp _ TiTrqDyn _ C and ACComp _ TiTrqResv _ C, characters corresponding to the initial letters AAA of all variable names are converted into 16-system numbers, C3 is obtained by adding and summing, and the overflow part of the sum is not calculated, then C3 is used as the variable name authentication information of 1 authentication byte.
The variable number authentication information includes 1 authentication byte, for example, there are 312 variables in the ini file, the converted 16-ary number is 138, the overflow part after the conversion is not counted, only the 16-ary number of the lowest two bits is reserved, and then 38 is used as the variable number authentication information of 1 authentication byte.
S220, determining the legal use starting time and the legal use ending time of the current flash ini file, and determining the time stamp of the configuration ini file according to the legal use starting time and the legal use ending time.
In an embodiment, the time stamp of the configuration ini file includes 7 authentication bytes, for example, if the legal use time of the ini file is set from 8 months 1 days in 2021 to 12 months 1 days in 2021, the value 2021080120211201 is obtained and converted into a 16-ary number 72E2962A0B701 with a length of 7 bytes, and if the number is less than 7 bytes, the number is complemented with 0 in the high order, and the 072E2962A0B701 is the time stamp of the configuration ini file with 7 authentication bytes.
And S230, determining the ini file authentication information corresponding to the current flash ini file according to the ECU version authentication information, the variable name authentication information, the variable number authentication information and the timestamp of the configuration ini file.
In this embodiment, the ini file authentication information includes 10 authentication bytes; the ECU version authentication information comprises 1 authentication byte, the variable name authentication information comprises 1 authentication byte, the variable number authentication information comprises 1 authentication byte, and the time stamp of the configuration ini file comprises 7 authentication bytes.
On the basis, the ECU version authentication information, the variable name authentication information, the variable number authentication information, and the time stamp of the configuration ini file collectively form ini file authentication information corresponding to the current flash ini file, that is, the ini file authentication information is 1B C338072E 2962a0B701, and 10 authentication bytes are counted.
S240, generating a target ini file containing the ini file authentication information.
Specifically, when an ini file is generated, the ini file authentication information of the current brushing ini file is added, and a target ini file containing the ini file authentication information is obtained.
And S250, storing the target ini file into a memory.
Specifically, the generated ini file and ini file authentication information, namely the target ini file, are recorded, and the ini file authentication information are stored in a memory of a program system, so that the generation information of the corresponding ini file can be inquired through the ini file authentication information in the following process.
In another embodiment, the current use time of the ini file to be refreshed, and the legal use starting time and the legal use ending time corresponding to the ini file to be refreshed are obtained; if the current use time is between the legal use starting time and the legal use ending time, the ini file to be rewritten is considered to pass the ini file authentication; and if the current use time is not between the legal use starting time and the legal use ending time, stopping the flashing process of the ini file to be flashed.
According to the technical scheme of the embodiment of the invention, the ini file authentication information is added when the ini file is generated, and the ini file authentication information contains 10 length authentication bytes, namely 10 length authentication bytes are added in the ini file, so that the function of encrypting the ini file can be realized, the ini file is safer, the written data and content of the ini file are effectively prevented from being maliciously tampered by a client, the information safety of a system and a terminal is ensured, meanwhile, the generation information and the corresponding content of the ini file can be traced, and the historical record of the ini file can be conveniently inquired. On the other hand, the ini file authentication information includes a time stamp for arranging the ini file, and defines a valid use time of the ini file.
EXAMPLE III
Fig. 3 is a structural diagram of an ini file generating device according to a third embodiment of the present invention, which is applicable to a case where encryption and authentication of an ini file are effectively managed.
As shown in fig. 3, the apparatus for generating an ini file includes: aninformation generation module 310 and afile generation module 320, wherein:
theinformation generating module 310 is configured to determine the ini file configuration parameter information of the current brushing ini file and a timestamp for configuring the ini file;
thefile generating module 320 is configured to determine ini file authentication information corresponding to the current flashing ini file according to the ini file configuration parameter information and the timestamp of the configuration ini file, and generate a target ini file including the ini file authentication information.
The generating device of the ini file of the embodiment is used for generating the ini file by determining the ini file configuration parameter information of the current flash ini file and the timestamp for configuring the ini file; and determining ini file authentication information corresponding to the current flash ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file, and generating a target ini file containing the ini file authentication information. The problem that the system information and data are easily tampered due to lack of effective management on the ini file at the present stage, and data safety of a client during generating and using the ini file cannot be guaranteed is solved, so that the safety of the ini file is improved, and the safety of configuration information is protected.
On the basis of the above embodiments, the ini file configuration parameter information includes ECU version authentication information, variable name authentication information, and variable number authentication information;
determining the ini file authentication information corresponding to the current flashing ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file comprises the following steps:
and determining the ini file authentication information corresponding to the current flash ini file according to the ECU version authentication information, the variable name authentication information, the variable number authentication information and the timestamp of the configuration ini file.
On the basis of the above embodiments, the ini file authentication information includes 10 authentication bytes;
the ECU version authentication information comprises 1 authentication byte, the variable name authentication information comprises 1 authentication byte, the variable number authentication information comprises 1 authentication byte, and the time stamp of the configuration ini file comprises 7 authentication bytes.
On the basis of the above embodiments, the ECU version authentication information, the variable name authentication information, the variable number authentication information, and the time stamp of the configuration ini file are arranged in 16-ary numbers.
On the basis of the above embodiments, determining the timestamp of the configuration ini file of the current brushing ini file includes:
and determining the legal use starting time and the legal use ending time of the current flash ini file, and determining the time stamp of the configuration ini file according to the legal use starting time and the legal use ending time.
On the basis of the foregoing embodiments, the apparatus for generating an ini file further includes:
the time acquisition module is used for acquiring the current use time of the ini file to be refreshed, and the legal use starting time and the legal use ending time corresponding to the ini file to be refreshed;
the flash judging module is used for considering that the ini file to be flashed passes the ini file authentication if the current use time is between the legal use starting time and the legal use ending time; and if the current use time is not between the legal use starting time and the legal use ending time, stopping the flashing process of the ini file to be flashed.
On the basis of the foregoing embodiments, the apparatus for generating an ini file further includes:
and the file storage module is used for storing the target ini file into a memory.
The apparatus for generating an ini file provided in the foregoing embodiments may execute the method for generating an ini file provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the method for generating an ini file.
Example four
Fig. 4 is a schematic structural diagram of a computer apparatus according to a fourth embodiment of the present invention, as shown in fig. 4, the computer apparatus includes aprocessor 410, amemory 420, aninput device 430, and anoutput device 440; the number of theprocessors 410 in the computer device may be one or more, and oneprocessor 410 is taken as an example in fig. 4; theprocessor 410, thememory 420, theinput device 430 and theoutput device 440 in the computer apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 4.
Thememory 420, which is a computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the method for generating an ini file in the embodiment of the present invention (for example, theinformation generating module 310 and thefile generating module 320 in the device for generating an ini file). Theprocessor 410 executes various functional applications and data processing of the computer device by executing software programs, instructions and modules stored in thememory 420, that is, the method for generating the ini file described above is implemented.
Thememory 420 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, thememory 420 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples,memory 420 may further include memory located remotely fromprocessor 410, which may be connected to a computer device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Theinput device 430 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer apparatus. Theoutput device 440 may include a display device such as a display screen.
EXAMPLE five
An embodiment of the present invention further provides a storage medium containing computer-executable instructions, where the computer-executable instructions are executed by a computer processor to perform a method for generating an ini file, where the method for generating an ini file includes:
determining the ini file configuration parameter information of the current flash ini file and the timestamp for configuring the ini file;
and determining ini file authentication information corresponding to the current flash ini file according to the ini file configuration parameter information and the time stamp of the configuration ini file, and generating a target ini file containing the ini file authentication information.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also perform related operations in the method for generating an ini file provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the apparatus for generating an ini file, each unit and each module included in the embodiment are only divided according to functional logic, but are not limited to the above division as long as the corresponding function can be realized; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.