A fixed value file encryption method and related device

By hashing the fixed value files in the relay protection device by the hash calculation of the State Secret SM3 and SHA256 algorithms, encrypted fixed value files are generated, which solves the security risks in the data storage and call process, and improves the reliability of the device's behavior judgment.

CN113742754BActive Publication Date: 2025-02-18GUANGDONG POWER GRID CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111081739.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-15
Publication Date
2025-02-18
Estimated Expiration
2041-09-15

AI Technical Summary

Technical Problem

Frequent data storage and call processes in existing relay protection devices can easily cause data security risks and affect the device's behavioral judgment.

Method used

The fixed value file hash calculations through the Guomi SM3 algorithm and the SHA256 algorithm, generate the first and second hash values, and merge them with the current fixed value file to generate the target encrypted fixed value file.

Benefits of technology

It increases the security of fixed value files, improves the reliability of storage and call operation processes, and prevents data security risks from affecting the device's behavioral judgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113742754B_ABST
    Figure CN113742754B_ABST
Patent Text Reader

Abstract

The present application discloses a method for encrypting a fixed value file and a related device, the method comprising: performing a first hash calculation on the current fixed value file through the national secret SM3 algorithm to obtain a first hash value; performing a second hash calculation on the current fixed value file through the SHA256 algorithm to obtain a second hash value; generating a target encrypted fixed value file according to the first hash value, the second hash value and the current fixed value file. Whether the file is called or stored, it is an operation on the encrypted fixed value file, and decryption processing is required, which increases the security of the fixed value file and improves the reliability of the storage and call operation process. The present application solves the technical problem that the frequent data storage and call process in the existing relay protection device is prone to data security risks, thereby affecting the behavior judgment of the device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information encryption technology, and in particular to a fixed-value file encryption method and related devices. Background Art

[0002] In relay protection devices, the amount of programs and data is relatively large, and much of the data is stored in the flash in the form of files and loaded into the memory when needed. During the use of the relay protection device in the project, a large number of files such as fixed values, events, logs, etc. need to be recorded. Frequent file operations and possible power supply abnormalities on site will cause hidden dangers to the stable operation of the file system and affect the safe and stable operation of the device. In particular, important files (such as fixed value files) will affect the behavior judgment of the device, resulting in false operation and endangering the stable operation of the power grid. Summary of the invention

[0003] The present application provides a fixed value file encryption method and related devices, which are used to solve the technical problem that frequent data storage and call processes in existing relay protection devices are prone to data security risks, thereby affecting the behavior judgment of the device.

[0004] In view of this, the first aspect of the present application provides a method for encrypting a fixed value file, comprising:

[0005] Perform a first hash calculation on the current fixed value file using the national secret SM3 algorithm to obtain a first hash value;

[0006] Performing a second hash calculation on the current fixed value file using the SHA256 algorithm to obtain a second hash value;

[0007] A target encrypted fixed value file is generated according to the first hash value, the second hash value and the current fixed value file.

[0008] Optionally, the step of generating a target encrypted fixed value file according to the first hash value, the second hash value and the current fixed value file further includes:

[0009] Determine whether the target fixed value file exists. If so, use the target encrypted fixed value file to overwrite the target fixed value file. If not, store the target encrypted fixed value file as the target fixed value file.

[0010] Optionally, the generating a target encrypted fixed-value file according to the first hash value, the second hash value and the current fixed-value file further includes:

[0011] Recording the current serial number, the latest modification time and the record check code of the adjacent files in the target encrypted fixed value file;

[0012] The accident file is retroactively analyzed according to the current serial number, the latest modification time and the record check code of the adjacent file.

[0013] Optionally, the step of generating a target encrypted fixed value file according to the first hash value, the second hash value and the current fixed value file further includes:

[0014] When reading the current fixed value file, a self-check operation is performed on the target encrypted file, and the reading operation is allowed if the check passes.

[0015] A second aspect of the present application provides a fixed value file encryption device, comprising:

[0016] A first calculation module is used to perform a first hash calculation on the current fixed value file by using the national secret SM3 algorithm to obtain a first hash value;

[0017] A second calculation module, used for performing a second hash calculation on the current fixed value file through a SHA256 algorithm to obtain a second hash value;

[0018] The file encryption module is used to generate a target encrypted fixed-value file according to the first hash value, the second hash value and the current fixed-value file.

[0019] Optionally, also include:

[0020] The storage judgment module is used to judge whether the target fixed value file exists. If so, the target encrypted fixed value file is used to overwrite the target fixed value file. If not, the target encrypted fixed value file is stored as the target fixed value file.

[0021] Optionally, also include:

[0022] An information recording module, used to record the current serial number, the latest modification time and the record check code of the adjacent file in the target encrypted fixed value file;

[0023] The accident tracing module is used to perform a tracing analysis on the accident file according to the current serial number, the latest modification time and the record check code of the adjacent file.

[0024] Optionally, also include:

[0025] The read verification module is used to perform a self-verification operation on the target encrypted file when reading the current fixed value file, and the read operation is allowed if the verification passes.

[0026] A third aspect of the present application provides a fixed-value file encryption device, the device comprising a processor and a memory;

[0027] The memory is used to store program code and transmit the program code to the processor;

[0028] The processor is used to execute the fixed value file encryption method described in the first aspect according to the instructions in the program code.

[0029] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program code, and the program code is used to execute the fixed value file encryption method described in the first aspect.

[0030] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0031] In the present application, a method for encrypting a fixed value file is provided, including: performing a first hash calculation on a current fixed value file by using the national encryption SM3 algorithm to obtain a first hash value; performing a second hash calculation on the current fixed value file by using the SHA256 algorithm to obtain a second hash value; and generating a target encrypted fixed value file according to the first hash value, the second hash value and the current fixed value file.

[0032] The fixed value file encryption method provided by the present application uses the national secret SM3 algorithm and the SHA256 algorithm to perform encryption calculation processing on the same current fixed value file respectively, obtains different hash values, and generates a target encrypted fixed value file together with the two hash values ​​and the current fixed value file. Whether the file is called or stored, it is an operation on the encrypted fixed value file, and it needs to be decrypted, which increases the security of the fixed value file and improves the reliability of the storage and call operation process. Therefore, the present application can solve the technical problem that the frequent data storage and call process in the existing relay protection device is prone to data security risks, thereby affecting the behavior judgment of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 A flowchart of a method for encrypting a fixed value file provided in an embodiment of the present application;

[0034] Figure 2 A schematic diagram of the structure of a fixed value file encryption device provided in an embodiment of the present application;

[0035] Figure 3 A schematic diagram of the constant value file stream storage structure provided in an embodiment of the present application. DETAILED DESCRIPTION

[0036] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0037] For easier understanding, see Figure 1 , an embodiment of a fixed value file encryption method provided by the present application includes:

[0038] Step 101: Perform a first hash calculation on the current fixed value file using the national encryption SM3 algorithm to obtain a first hash value.

[0039] The National Cryptography SM3 algorithm is a cryptographic hash function standard, which is mainly used in commercial cryptographic systems for digital signatures and verification, message authentication code generation and verification, random number generation, etc. A cryptographic hash function is a one-way function, which means that it is difficult to infer the input data from the output of the hash function; the input data of this hash function is called a message, and the output result calculated by the hash function is called a message digest.

[0040] The hash value is represented by a short string of random letters and numbers; in this embodiment, the national secret SM3 algorithm is used to perform a first hash calculation on the current fixed value file to obtain a 32-byte first hash value corresponding to the fixed value file; that is, the 32-byte message digest obtained after encryption using the national secret SM3 algorithm.

[0041] Step 102: Perform a second hash calculation on the current fixed value file using the SHA256 algorithm to obtain a second hash value.

[0042] The hash value length used by the SHA256 algorithm is 256 bits, which means that the message digest length calculated by this algorithm is 256 bits. It is also a hash function, or hash algorithm. It can compress messages or data into digests, making the data volume smaller and fixing the format of the data. The preprocessing in the SHA256 algorithm is to add the required information after the hash message so that the entire message meets the specified structure.

[0043] In this embodiment, the SHA256 algorithm is used to perform a second hash calculation on the current fixed value file to obtain a corresponding 32-byte second hash value, that is, a 32-byte message digest obtained by using the SHA256 algorithm.

[0044] Step 103: Generate a target encrypted fixed value file according to the first hash value, the second hash value and the current fixed value file.

[0045] The first hash value, the second hash value and the current fixed value file are merged and stored as a target encrypted fixed value file; thus, each call and modification of the fixed value file requires a decryption operation.

[0046] Furthermore, step 103 further includes:

[0047] Determine whether the target fixed value file exists. If so, use the target encrypted fixed value file to overwrite the target fixed value file. If not, store the target encrypted fixed value file as the target fixed value file.

[0048] The storage process of the target fixed value file is not directly determined by the target encrypted fixed value file, but is first used as an intermediate file for judgment operations; if the file already exists, the newly generated intermediate file needs to overwrite the originally stored target fixed value file, that is, the original file is deleted; if it does not exist, the target encrypted fixed value file can be directly named and stored.

[0049] Furthermore, step 103 further includes:

[0050] Record the current serial number, the latest modification time and the record check code of the adjacent files in the target encrypted fixed value file;

[0051] The accident file is traced and analyzed based on the current serial number, the latest modification time and the record check code of the adjacent files.

[0052] After the current fixed value file is encrypted, the record check code of the previous adjacent file is saved, and the sequence number of the current fixed value file and the latest modification time, that is, the current modification time, are also recorded. The recorded current sequence number, latest modification time, and record check code of the adjacent file can be used to trace the call, encryption or storage process and analyze the cause of the accident in the event of an accident in the file. For the specific structure, please refer to Figure 3 .

[0053] Furthermore, step 103 further includes:

[0054] When reading the current constant value file, a self-check operation is performed on the target encrypted file. If the check passes, the reading operation is allowed.

[0055] The encrypted fixed value file needs to perform a self-verification and comparison operation when reading the request. If the decrypted fixed value file is consistent with the preset file, the verification passes. Otherwise, the verification fails and an alarm prompt can be directly returned or an error response can be returned.

[0056] The fixed value file encryption method provided in the embodiment of the present application uses the national secret SM3 algorithm and the SHA256 algorithm to perform encryption calculation processing on the same current fixed value file respectively, obtains different hash values, and generates a target encrypted fixed value file together with the two hash values ​​and the current fixed value file. Whether the file is called or stored, it is an operation on the encrypted fixed value file, and it needs to be decrypted, which increases the security of the fixed value file and improves the reliability of the storage and call operation process. Therefore, the embodiment of the present application can solve the technical problem that the frequent data storage and call process in the existing relay protection device is prone to data security risks, thereby affecting the behavior judgment of the device.

[0057] For easier understanding, see Figure 2 The present application provides an embodiment of a fixed value file encryption device, comprising:

[0058] The first calculation module 201 is used to perform a first hash calculation on the current fixed value file by using the national secret SM3 algorithm to obtain a first hash value;

[0059] The second calculation module 202 is used to perform a second hash calculation on the current fixed value file through the SHA256 algorithm to obtain a second hash value;

[0060] The file encryption module 203 is used to generate a target encrypted fixed-value file according to the first hash value, the second hash value and the current fixed-value file.

[0061] Furthermore, it also includes:

[0062] The storage determination module 204 is used to determine whether the target fixed value file exists. If so, the target encrypted fixed value file is used to overwrite the target fixed value file. If not, the target encrypted fixed value file is stored as the target fixed value file.

[0063] Furthermore, it also includes:

[0064] Information recording module 205, used to record the current serial number, the latest modification time and the record check code of the adjacent file in the target encrypted fixed value file;

[0065] The accident tracing module 206 is used to perform a tracing analysis on the accident file according to the current sequence number, the latest modification time and the record check code of the adjacent files.

[0066] Furthermore, it also includes:

[0067] The read verification module 207 is used to perform a self-verification operation on the target encrypted file when reading the current fixed value file, and the read operation is allowed if the verification passes.

[0068] The present application also provides a fixed-value file encryption device, the device comprising a processor and a memory;

[0069] The memory is used to store the program code and transmit the program code to the processor;

[0070] The processor is used to execute the fixed value file encryption method in the above method embodiment according to the instructions in the program code.

[0071] The present application also provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the fixed value file encryption method in the above method embodiment.

[0072] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0073] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0074] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0075] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for executing all or part of the steps of the method described in each embodiment of the present application through a computer device (which can be a personal computer, a server, or a network device, etc.). The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (full name in English: Read-Only Memory, English abbreviation: ROM), random access memory (full name in English: Random Access Memory, English abbreviation: RAM), disk or optical disk and other media that can store program codes.

[0076] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for encrypting a fixed value file, characterized in that: include: Perform a first hash calculation on the current fixed value file using the national secret SM3 algorithm to obtain a first hash value; Performing a second hash calculation on the current fixed value file using the SHA256 algorithm to obtain a second hash value; Generate a target encrypted fixed value file according to the first hash value, the second hash value and the current fixed value file; Recording the current serial number, the latest modification time and the record check code of the adjacent files in the target encrypted fixed value file; Performing retrospective analysis on the accident file according to the current serial number, the latest modification time and the record check code of the adjacent file; Determine whether the target fixed value file exists, if so, use the target encrypted fixed value file to overwrite the target fixed value file, if not, store the target encrypted fixed value file as the target fixed value file; When reading the current fixed value file, a self-check operation is performed on the target fixed value file, and the reading operation is allowed if the check passes.

2. A fixed value file encryption device, characterized in that: include: A first calculation module is used to perform a first hash calculation on the current fixed value file by using the national secret SM3 algorithm to obtain a first hash value; A second calculation module, used for performing a second hash calculation on the current fixed value file through a SHA256 algorithm to obtain a second hash value; A file encryption module, used for generating a target encrypted fixed-value file according to the first hash value, the second hash value and the current fixed-value file; An information recording module, used to record the current serial number, the latest modification time and the record check code of the adjacent file in the target encrypted fixed value file; An accident tracing module is used to perform a tracing analysis on the accident file according to the current sequence number, the latest modification time and the record check code of the adjacent file; A storage judgment module is used to judge whether a target fixed value file exists. If so, the target encrypted fixed value file is used to overwrite the target fixed value file. If not, the target encrypted fixed value file is stored as the target fixed value file. The read verification module is used to perform a self-verification operation on the target fixed value file when reading the current fixed value file, and the read operation is allowed if the verification passes.

3. A fixed value file encryption device, characterized in that: The device comprises a processor and a memory; The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the fixed value file encryption method according to claim 1 according to the instructions in the program code.

4. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program code, and the program code is used to execute the fixed value file encryption method described in claim 1.

Citation Information

Patent Citations

  • Constant value correcting method and device of failure information main station, and power system device

    CN102364511A

  • File signature method and device and file signature verification method and device

    CN111125781A