Data storage method and device of electric energy meter, computer equipment, storage medium and computer program product

By generating a secret key value and a hash value in the electricity meter and performing double verification based on the data length, the instability problem of traditional electricity meter data storage during program upgrades is solved, achieving higher data storage security and stability.

CN120669919AActive Publication Date: 2025-09-19ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510802543.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-16
Publication Date
2025-09-19
Estimated Expiration
2045-06-16

AI Technical Summary

Technical Problem

The traditional electricity meter data storage method is prone to cause storage address changes during program upgrades, resulting in data misalignment and low storage security.

Method used

By obtaining the row number value of the data to be stored, generating the secret key value, calculating the target hash value and check code, and performing double verification in combination with the data length, the dynamic association between the storage location and the data content is ensured, forming a composite verification mechanism.

Benefits of technology

Effectively prevent data tampering and unauthorized access, improve data storage security, avoid data dislocation problems caused by program upgrades, and enhance the stability and security of data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120669919A_ABST
    Figure CN120669919A_ABST
Patent Text Reader

Abstract

The invention relates to a data storage method and device of an electric energy meter, computer equipment, a storage medium and a computer program product. The method comprises the following steps: determining a secret key value of to-be-stored data according to a line number value of the to-be-stored data associated with the electric energy meter in a storage table of the electric energy meter; determining a target hash value of the to-be-stored data according to the secret key value and the data length of the to-be-stored data; determining an initial check code of each sub-data in the to-be-stored data according to the secret key value and the target hash value; according to the secret key value and the data length, updating the initial check code of each piece of sub-data to obtain an updated check code of each piece of sub-data; performing combination processing on the updated check code of each sub-data to obtain a target check code of the to-be-stored data; and storing the to-be-stored data and the target check code of the to-be-stored data into a storage table of the electric energy meter according to the line number value. By adopting the method, the security of data storage can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of power grid technology, and in particular to a data storage method, device, computer equipment, computer-readable storage medium, and computer program product for an electric energy meter. Background Art

[0002] As an important component of the power system, the data storage performance and reliability of the energy meter are of great significance to the operation and management of the power system. Therefore, how to store the energy meter data securely is of vital importance.

[0003] Traditionally, random access memory (RAM) is used to store electricity meter data. However, this method can easily cause instabilities such as data misalignment when the storage address changes during program upgrades, resulting in lower data storage security. Summary of the Invention

[0004] Based on this, it is necessary to provide a data storage method, device, computer equipment, computer-readable storage medium and computer program product for an electric energy meter that can improve the security of data storage in order to address the above technical problems.

[0005] In a first aspect, the present application provides a data storage method for an electric energy meter, comprising:

[0006] Acquire data to be stored associated with the electric energy meter, and determine a row number value corresponding to the data to be stored in a storage table of the electric energy meter;

[0007] Determining a secret key value corresponding to the data to be stored according to the row number value;

[0008] Obtaining the data length corresponding to the data to be stored, and determining the target hash value corresponding to the data to be stored based on the secret key value and the data length;

[0009] Determining an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value;

[0010] updating the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain an updated check code corresponding to each sub-data;

[0011] Combining the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored;

[0012] According to the row number value, the data to be stored and the target check code corresponding to the data to be stored are stored in the storage table of the electric energy meter.

[0013] In one embodiment, determining the key value corresponding to the data to be stored according to the row number value includes:

[0014] Performing a first nonlinear transformation on the row number value to obtain a multiplier value corresponding to the data to be stored, and performing a second nonlinear transformation on the row number value to obtain an offset corresponding to the data to be stored;

[0015] Determining, according to the row number value, the multiplier value, and the offset, a confusion factor corresponding to the data to be stored;

[0016] Determining a seed value corresponding to the data to be stored according to the row number value, the multiplier value, the offset, and the confusion factor;

[0017] The multiplier value, the offset, the confusion factor, and the seed value are all used as the secret key value corresponding to the data to be stored.

[0018] In one embodiment, determining a target hash value corresponding to the data to be stored based on the key value and the data length includes:

[0019] Using the seed value as the initial hash value corresponding to the data to be stored;

[0020] Updating the initial hash value to obtain an updated hash value corresponding to the data to be stored;

[0021] Obtaining the update number corresponding to the updated hash value, using the updated hash value as a new initial hash value, and jumping to the step of updating the initial hash value to obtain the updated hash value corresponding to the data to be stored, until the update number meets a preset update number; the preset update number is determined by the data length;

[0022] The updated hash value that satisfies the preset update times is used as the target hash value corresponding to the data to be stored.

[0023] In one embodiment, updating the initial hash value to obtain an updated hash value corresponding to the data to be stored includes:

[0024] updating the initial hash value according to each sub-data and the multiplier value to obtain a processed hash value corresponding to the data to be stored;

[0025] Performing a cyclic shift process on the processed hash value to obtain an updated hash value corresponding to the data to be stored.

[0026] In one embodiment, determining the initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value includes:

[0027] Obtaining a current position value corresponding to each sub-data in the data to be stored;

[0028] Determining a position factor corresponding to each sub-data according to the current position value corresponding to each sub-data, the offset, and the confusion factor, and determining a hash bit corresponding to each sub-data according to the target hash value and the current position value;

[0029] An initial check code corresponding to each sub-data is determined according to each sub-data, the position factor and the hash bit.

[0030] In one embodiment, updating the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain the updated check code corresponding to each sub-data includes:

[0031] updating the initial check code corresponding to each sub-data according to the current position value corresponding to each sub-data, the confusion factor, and the data length, to obtain a processed check code corresponding to each sub-data;

[0032] An updated check code corresponding to each sub-data is determined according to the processed check code and the initial check code corresponding to each sub-data.

[0033] In a second aspect, the present application further provides a data storage device for an electric energy meter, comprising:

[0034] a row number value determination module, configured to obtain data to be stored associated with the electric energy meter, and determine a row number value corresponding to the data to be stored in a storage table of the electric energy meter;

[0035] A key value determination module, configured to determine a key value corresponding to the data to be stored according to the row number value;

[0036] A hash value determination module is used to obtain the data length corresponding to the data to be stored, and determine the target hash value corresponding to the data to be stored according to the secret key value and the data length;

[0037] a check code determination module, configured to determine an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value;

[0038] a check code updating module, configured to update the initial check code corresponding to each sub-data according to the secret key value and the data length, to obtain an updated check code corresponding to each sub-data;

[0039] a check code combination module, configured to combine the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored;

[0040] The data storage module is used to store the data to be stored and the target check code corresponding to the data to be stored in the storage table of the electric energy meter according to the row number value.

[0041] In a third aspect, the present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0042] Acquire data to be stored associated with the electric energy meter, and determine a row number value corresponding to the data to be stored in a storage table of the electric energy meter;

[0043] Determining a secret key value corresponding to the data to be stored according to the row number value;

[0044] Obtaining the data length corresponding to the data to be stored, and determining the target hash value corresponding to the data to be stored based on the secret key value and the data length;

[0045] Determining an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value;

[0046] updating the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain an updated check code corresponding to each sub-data;

[0047] Combining the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored;

[0048] According to the row number value, the data to be stored and the target check code corresponding to the data to be stored are stored in the storage table of the electric energy meter.

[0049] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0050] Acquire data to be stored associated with the electric energy meter, and determine a row number value corresponding to the data to be stored in a storage table of the electric energy meter;

[0051] Determining a secret key value corresponding to the data to be stored according to the row number value;

[0052] Obtaining the data length corresponding to the data to be stored, and determining the target hash value corresponding to the data to be stored based on the secret key value and the data length;

[0053] Determining an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value;

[0054] updating the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain an updated check code corresponding to each sub-data;

[0055] Combining the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored;

[0056] According to the row number value, the data to be stored and the target check code corresponding to the data to be stored are stored in the storage table of the electric energy meter.

[0057] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the following steps:

[0058] Acquire data to be stored associated with the electric energy meter, and determine a row number value corresponding to the data to be stored in a storage table of the electric energy meter;

[0059] Determining a secret key value corresponding to the data to be stored according to the row number value;

[0060] Obtaining the data length corresponding to the data to be stored, and determining the target hash value corresponding to the data to be stored based on the secret key value and the data length;

[0061] Determining an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value;

[0062] updating the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain an updated check code corresponding to each sub-data;

[0063] Combining the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored;

[0064] According to the row number value, the data to be stored and the target check code corresponding to the data to be stored are stored in the storage table of the electric energy meter.

[0065] The data storage method, device, computer equipment, storage medium and computer program product of the above-mentioned electric energy meter first obtains the data to be stored associated with the electric energy meter, and determines the row number value corresponding to the data to be stored in the storage table of the electric energy meter, and then determines the secret key value corresponding to the data to be stored based on the row number value, and obtains the data length corresponding to the data to be stored, and determines the target hash value corresponding to the data to be stored based on the secret key value and the data length, and then determines the initial check code corresponding to each sub-data in the data to be stored based on the secret key value and the target hash value, and updates the initial check code corresponding to each sub-data based on the secret key value and the data length to obtain the updated check code corresponding to each sub-data, and then combines the updated check code corresponding to each sub-data to obtain the target check code corresponding to the data to be stored, and finally, stores the data to be stored and the target check code corresponding to the data to be stored in the storage table of the electric energy meter according to the row number value. In this way, when storing the data of the electricity meter, the row number value is first determined based on the data to be stored and the corresponding secret key value is generated, so that the secret key is dynamically associated with the storage location, and then the target hash value is calculated in combination with the secret key value and the data length to ensure that the hash value depends on both the data content and the storage environment. Then, the secret key value and the hash value are used to generate the sub-data initial check code, and then the check code is updated in combination with the data length to form a double check. Finally, the updated check code is combined to obtain the target check code and stored synchronously with the data. This method of deeply coupling the storage location, data length and encryption check can effectively prevent data tampering, forgery of storage location and unauthorized access, which is conducive to improving the security of data storage. Moreover, the above process avoids the defect that when the storage address is prone to change during program upgrades, it is easy to cause instability such as data dislocation, resulting in low data storage security, thereby further improving the security of data storage. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.

[0067] Figure 1 A schematic flow chart of a data storage method for an electric energy meter in one embodiment;

[0068] Figure 2 A schematic flow chart of a data storage method for an electric energy meter in another embodiment;

[0069] Figure 3 1 is a flow chart of a method for calculating a check code in one embodiment;

[0070] Figure 4 is a structural block diagram of a data storage device of an electric energy meter in one embodiment;

[0071] Figure 5 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0072] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0073] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0074] In an exemplary embodiment, Figure 1 As shown, a method for storing data in an electric energy meter is provided. This embodiment uses the method applied to a server as an example for illustration; it is understood that the method can also be applied to a terminal, or to a system including a terminal and a server, and implemented through interaction between the terminal and the server. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, and tablet computers; the server can be implemented as an independent server or a server cluster consisting of multiple servers. In this embodiment, the method includes the following steps:

[0075] Step S101 : acquiring data to be stored associated with the electric energy meter, and determining a row number value corresponding to the data to be stored in a storage table of the electric energy meter.

[0076] Among them, the electric energy meter refers to an instrument used to measure electric energy.

[0077] The data to be stored refers to data that needs to be stored.

[0078] The storage table refers to a data storage table established inside the electric energy meter.

[0079] The row number value is used to indicate the row position number corresponding to the data to be stored in the built-in storage table of the electric energy meter.

[0080] Exemplarily, the server obtains electrical parameter data (such as voltage data, current data, etc.), status data (such as operating status data, hardware status data) and auxiliary data (such as timestamp, etc.) associated with the electric energy meter by connecting to the data interface of the electric energy meter; then, the server preprocesses the electrical parameter data, status data and auxiliary data to obtain preprocessed electrical parameter data, preprocessed status data and preprocessed auxiliary data corresponding to the electric energy meter; then, the server combines the preprocessed electrical parameter data, preprocessed status data and preprocessed auxiliary data corresponding to the electric energy meter according to a preset combination method to obtain data to be stored associated with the electric energy meter; then, the server determines the row number value corresponding to the data to be stored in the storage table of the electric energy meter according to the storage order corresponding to the data to be stored.

[0081] Step S102: Determine the key value corresponding to the data to be stored according to the row number value.

[0082] The secret key value includes at least a multiplier value, an offset, a confusion factor, and a seed value corresponding to the data to be stored.

[0083] Exemplarily, the server queries the correspondence between the row number value and the key value based on the row number value, and obtains the key value corresponding to the data to be stored.

[0084] Step S103: Obtain the data length corresponding to the data to be stored, and determine the target hash value corresponding to the data to be stored based on the secret key value and the data length.

[0085] The data length is used to indicate the number of bytes of data to be stored.

[0086] The target hash value is used to represent the unique summary value corresponding to the data to be stored.

[0087] Exemplarily, the server performs byte alignment on the data to be stored to obtain the processed data to be stored, and uses the data length corresponding to the processed data to be stored as the data length corresponding to the data to be stored; then, the server inputs the secret key value and the data length into multiple hash value prediction models to obtain multiple predicted hash values ​​corresponding to the data to be stored, and fuses the multiple predicted hash values ​​corresponding to the data to be stored according to the model weight of each hash value prediction model to obtain the target hash value corresponding to the data to be stored.

[0088] Step S104: determining an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value.

[0089] The sub-data refers to the smallest data unit in the data to be stored.

[0090] The initial check code refers to the check code corresponding to each sub-data in the data to be stored, determined based on the secret key value and the target hash value.

[0091] Exemplarily, the server performs verification processing on the target hash value to obtain a verification result of the target hash value; when the verification result of the target hash value indicates that the target hash value passes, the server determines the verification code corresponding to each sub-data in the data to be stored based on the secret key value and the target hash value, as the initial verification code corresponding to each sub-data in the data to be stored.

[0092] Step S105 : updating the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain an updated check code corresponding to each sub-data.

[0093] The updated check code refers to a check code obtained by updating the initial check code corresponding to each sub-data based on the secret key value and the data length.

[0094] Exemplarily, the server extracts the key key value from the key value; then, the server updates the initial check code corresponding to each sub-data according to the key key value and the data length to obtain the updated check code corresponding to each sub-data.

[0095] Step S106 , combining the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored.

[0096] The target check code refers to a check code obtained by combining the updated check codes corresponding to each sub-data.

[0097] Exemplarily, the server combines the updated check codes corresponding to each sub-data according to the current position value corresponding to each sub-data to obtain a combined check code, and uses the combined check code as the target check code corresponding to the data to be stored.

[0098] Step S107 : storing the data to be stored and the target check code corresponding to the data to be stored into a storage table of the electric energy meter according to the row number value.

[0099] Exemplarily, the server encapsulates the data to be stored and the target check code corresponding to the data to be stored to obtain encapsulated data; then, the server stores the encapsulated data in a sub-storage table corresponding to the row number value in the storage table of the electric energy meter.

[0100] In the data storage method of the above-mentioned electric energy meter, the data to be stored associated with the electric energy meter is first obtained, and the row number value corresponding to the data to be stored in the storage table of the electric energy meter is determined, and then the secret key value corresponding to the data to be stored is determined according to the row number value, and the data length corresponding to the data to be stored is obtained, and the target hash value corresponding to the data to be stored is determined according to the secret key value and the data length, and then the initial check code corresponding to each sub-data in the data to be stored is determined according to the secret key value and the target hash value, and then, the initial check code corresponding to each sub-data in the data to be stored is determined, and according to the secret key value and the data length, the initial check code corresponding to each sub-data is updated to obtain the updated check code corresponding to each sub-data, and then, the updated check code corresponding to each sub-data is combined to obtain the target check code corresponding to the data to be stored, and finally, according to the row number value, the data to be stored and the target check code corresponding to the data to be stored are stored in the storage table of the electric energy meter. In this way, when storing the data of the electricity meter, the row number value is first determined based on the data to be stored and the corresponding secret key value is generated, so that the secret key is dynamically associated with the storage location, and then the target hash value is calculated in combination with the secret key value and the data length to ensure that the hash value depends on both the data content and the storage environment. Then, the secret key value and the hash value are used to generate the sub-data initial check code, and then the check code is updated in combination with the data length to form a double check. Finally, the updated check code is combined to obtain the target check code and stored synchronously with the data. This method of deeply coupling the storage location, data length and encryption check can effectively prevent data tampering, forgery of storage location and unauthorized access, which is conducive to improving the security of data storage. Moreover, the above process avoids the defect that when the storage address is prone to change during program upgrades, it is easy to cause instability such as data dislocation, resulting in low data storage security, thereby further improving the security of data storage.

[0101] In an exemplary embodiment, the above-mentioned step S102, determining the secret key value corresponding to the data to be stored based on the row number value, specifically includes the following contents: performing a first nonlinear transformation processing on the row number value to obtain a multiplier value corresponding to the data to be stored, and performing a second nonlinear transformation processing on the row number value to obtain an offset corresponding to the data to be stored; determining an obfuscation factor corresponding to the data to be stored based on the row number value, the multiplier value, and the offset; determining a seed value corresponding to the data to be stored based on the row number value, the multiplier value, the offset, and the obfuscation factor; and using the multiplier value, the offset, the obfuscation factor, and the seed value as the secret key value corresponding to the data to be stored.

[0102] The first nonlinear transformation process is the process of mapping the row number value to a multiplier value through a nonlinear function. In actual scenarios, the first nonlinear transformation process is the process of performing a nonlinear transformation process on the row number value, the prime number 17, and the constant 37.

[0103] The multiplier value refers to the multiplication factor corresponding to the data to be stored.

[0104] The second nonlinear transformation process refers to the operation process of mapping the row number value to an offset through a nonlinear function. In actual scenarios, the first nonlinear transformation process refers to the operation process corresponding to the nonlinear transformation process of the row number value, the prime number 23, and the constant 53.

[0105] The offset refers to the offset factor corresponding to the data to be stored.

[0106] The confusion factor refers to the confusion parameter generated by combining the row number value, the multiplier value, and the offset.

[0107] The seed value refers to the key seed generated by combining the row number value, the multiplier value, the offset, and the confusion factor.

[0108] Exemplarily, the server performs a nonlinear transformation on the row number value, the prime number 17, and the constant 37, and converts the transformed result into an unsigned 8-bit format to obtain the multiplier value corresponding to the data to be stored, and performs a nonlinear transformation on the row number value, the prime number 23, and the constant 53, takes the modulus of the transformed result with the prime number 251, and converts the modulus result into an unsigned 8-bit format to obtain the offset corresponding to the data to be stored; then, the server performs an XOR operation on the multiplier and the offset to obtain an XOR operation result, performs an AND operation on the row number and the hexadecimal number 0xff to obtain the low 8-bit data of the row number, and The XOR operation result and the lower 8 bits of the row number are ORed together to obtain the confusion factor corresponding to the data to be stored; then, the server inputs the row number value, multiplier value, offset, and confusion factor into the seed value prediction model (algorithm) to obtain the seed value corresponding to the data to be stored; wherein, the seed value can be calculated in the following manner: bits 31 to 16 of the seed value are generated by shifting the row number left by 16 bits, bits 15 to 8 are generated by shifting the confusion factor left by 8 bits, and bits 7 to 0 are generated by XORing the offset and the multiplier; then, the server uses the multiplier value, offset, confusion factor, and seed value as the secret key value corresponding to the data to be stored.

[0109] For example, the multiplier value can be calculated using the following formula:

[0110] , formula (1)

[0111] Where multiplier is the multiplier value, uint8_t is the unsigned 8-bit integer type, and row is the row number.

[0112] For example, the offset can be calculated using the following formula:

[0113] , formula (2)

[0114] Here, offset refers to the offset.

[0115] For example, the confusion factor can be calculated using the following formula:

[0116] , formula (3)

[0117] Among them, mix_factor refers to the confusion factor.

[0118] For example, the seed value can be calculated using the following formula:

[0119] , formula (4)

[0120] Here, seed refers to the seed value.

[0121] In this embodiment, the complexity and anti-exhaustiveness of the key space are enhanced through the combined calculation of multi-level parameters. Even if a certain level of parameters is leaked, it is difficult to reversely deduce the overall key. At the same time, it dynamically adapts to the key requirements of different row numbers, provides fine-grained, high-security key management for electricity meter data storage, and ensures the integrity and confidentiality of data during storage and transmission.

[0122] In an exemplary embodiment, the above step S103 determines the target hash value corresponding to the data to be stored based on the secret key value and the data length, and specifically includes the following contents: using the seed value as the initial hash value corresponding to the data to be stored; updating the initial hash value to obtain the updated hash value corresponding to the data to be stored; obtaining the number of updates corresponding to the updated hash value, and using the updated hash value as the new initial hash value, and jumping to the step of updating the initial hash value to obtain the updated hash value corresponding to the data to be stored, until the number of updates meets the preset number of updates; the preset number of updates is determined by the data length; and the updated hash value that meets the preset number of updates is used as the target hash value corresponding to the data to be stored.

[0123] The initial hash value refers to the initial value of the hash value corresponding to the data to be stored.

[0124] The updated hash value refers to a hash value obtained by updating the initial hash value.

[0125] The number of updates refers to the number of iterative updates of the initial hash value.

[0126] The preset update times refers to a preset update times, which is determined by the data length. For example, if the data length is 5, the preset update times is 5 times.

[0127] Exemplarily, the server uses the seed value as the initial hash value corresponding to the data to be stored; then, the server updates the initial hash value according to the update method corresponding to the initial hash value to obtain the updated hash value corresponding to the data to be stored; then, the server determines the preset number of updates corresponding to the updated hash value based on the data length, obtains the update number corresponding to the updated hash value, and uses the updated hash value as the new initial hash value, and jumps to the step of updating the initial hash value to obtain the updated hash value corresponding to the data to be stored, until the number of updates meets the preset number of updates; then, the server uses the updated hash value that meets the preset number of updates as the target hash value corresponding to the data to be stored.

[0128] For example, the initial hash value can be calculated using the following formula:

[0129] , formula (5)

[0130] In this embodiment, by utilizing the association mechanism between data length and update times, the hash calculation complexity is dynamically adjusted with the data scale, providing high-intensity hash protection that is deeply bound to the data features for the data to be stored, ensuring the uniqueness and anti-attack capability of the target hash value.

[0131] In an exemplary embodiment, the initial hash value is updated to obtain an updated hash value corresponding to the data to be stored, specifically including the following: updating the initial hash value according to each sub-data and the multiplier value to obtain a processed hash value corresponding to the data to be stored; and performing a cyclic shift on the processed hash value to obtain an updated hash value corresponding to the data to be stored.

[0132] The processed hash value refers to a hash value obtained by updating the initial hash value based on each sub-data and the multiplier value.

[0133] Exemplarily, the server first performs an XOR operation on each sub-data with the product of the initial hash value and the multiplier value, and then further performs an XOR operation on the XOR operation result with the initial hash value shifted right by 13 bits to obtain the processed hash value corresponding to the data to be stored; then, the server performs an XOR operation on the processed hash value shifted right by 27 bits and the processed hash value shifted left by 5 bits to obtain the updated hash value corresponding to the data to be stored.

[0134] For example, the processed hash value can be calculated using the following formula:

[0135] , formula (6)

[0136] Among them, data[i] refers to each sub-data.

[0137] For example, the updated hash value can be calculated using the following formula:

[0138] , formula (7)

[0139] In this embodiment, by utilizing the linkage update of the multiplier value and the sub-data, the hash calculation is integrated with the data characteristics and nonlinear transformation factors, the binding degree of the hash value and the original data is enhanced, and hash conflicts caused by changes in single data or multiplier values ​​are avoided, thereby providing more robust hash protection for the data to be stored and ensuring the reliability of data integrity verification.

[0140] In an exemplary embodiment, the above step S104 determines the initial check code corresponding to each sub-data in the data to be stored based on the secret key value and the target hash value, and specifically includes the following contents: obtaining the current position value corresponding to each sub-data in the data to be stored; determining the position factor corresponding to each sub-data based on the current position value, offset and confusion factor corresponding to each sub-data, and determining the hash bit corresponding to each sub-data based on the target hash value and the current position value; determining the initial check code corresponding to each sub-data based on each sub-data, the position factor and the hash bit.

[0141] The current position value is used to indicate the relative position of each sub-data in the data to be stored. In actual scenarios, the current position value is also called the current cycle value i.

[0142] The position factor refers to a nonlinear transformation value calculated by using the current position value, offset, and confusion factor of each sub-data.

[0143] The hash bit refers to a specific bit combination extracted from the target hash value that is related to the current position value.

[0144] Exemplarily, the server obtains the current position value corresponding to each sub-data in the data to be stored; then, the server multiplies the current position value corresponding to each sub-data by the confusion factor, adds the offset, and takes the remainder of the operation result with 256 to obtain the position factor corresponding to each sub-data; then, the server shifts the target hash value to the right by the number of bits corresponding to the current position value to obtain the hash bit corresponding to each sub-data; then, the server performs an XOR operation on each sub-data and the hash bit, and performs an XOR operation on the operation result with the position factor to obtain the initial check code corresponding to each sub-data.

[0145] For example, the position factor can be calculated using the following formula:

[0146] , formula (8)

[0147] Among them, pos_factor refers to the position factor.

[0148] For example, the hash bit can be calculated using the following formula:

[0149] , formula (9)

[0150] Among them, hash_bit refers to the hash bit.

[0151] For example, the initial check code can be calculated using the following formula:

[0152] , formula (10)

[0153] Wherein, checksum[i] refers to the initial check code corresponding to the i-th sub-data in the data to be stored.

[0154] In this embodiment, the initial verification code is generated by integrating data location characteristics, dynamic key parameters and global hash characteristics to achieve the binding of local verification and overall data integrity, ensuring that any change to sub-data will cause verification failure. At the same time, it takes into account fine-grained data verification and global consistency assurance, providing a multi-level, high-security integrity verification mechanism for data storage of equipment such as electricity meters.

[0155] In an exemplary embodiment, the above step S105 updates the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain the updated check code corresponding to each sub-data, which specifically includes the following contents: updating the initial check code corresponding to each sub-data according to the current position value, confusion factor and data length corresponding to each sub-data to obtain the processed check code corresponding to each sub-data; determining the updated check code corresponding to each sub-data according to the processed check code and the initial check code corresponding to each sub-data.

[0156] The processed check code refers to a check code obtained by updating the initial check code corresponding to each sub-data based on the current position value, confusion factor and data length corresponding to each sub-data.

[0157] Exemplarily, the server adds the current position value and the confusion factor corresponding to each sub-data, and then takes the modulus of the data length. The initial check code corresponding to the obtained operation result is used as the processed check code corresponding to each sub-data (for example, if the operation result is 5, the 5th check code is taken out); then, the server performs an XOR operation on the processed check code corresponding to each sub-data and the initial check code to obtain the updated check code corresponding to each sub-data.

[0158] For example, the updated checksum can be calculated using the following formula:

[0159] , formula (11)

[0160] Among them, Len refers to the data length.

[0161] In this embodiment, by adopting a composite verification mechanism, the initial verification code is doubly updated in combination with the data position characteristics, dynamic confusion factor and data length, which not only retains the integrity basis of the initial verification, but also incorporates dynamic security elements to achieve all-round protection of data content, location and length, significantly improving the security and anti-attack ability of the verification code, and providing more reliable integrity protection for data storage of equipment such as electricity meters.

[0162] In an exemplary embodiment, Figure 2 As shown, another data storage method for an electric energy meter is provided. This method is described by taking its application to a server as an example. Specifically, the method includes the following steps:

[0163] Step S201 : acquiring data to be stored associated with the electric energy meter, and determining a row number value corresponding to the data to be stored in a storage table of the electric energy meter.

[0164] Step S202: Perform a first nonlinear transformation on the row number value to obtain a multiplier value corresponding to the data to be stored, and perform a second nonlinear transformation on the row number value to obtain an offset corresponding to the data to be stored; and determine an obfuscation factor corresponding to the data to be stored based on the row number value, the multiplier value, and the offset.

[0165] Step S203: Determine a seed value corresponding to the data to be stored based on the row number value, the multiplier value, the offset, and the confusion factor; and use the multiplier value, the offset, the confusion factor, and the seed value as the secret key value corresponding to the data to be stored.

[0166] Step S204: Obtain the data length corresponding to the data to be stored, and determine the target hash value corresponding to the data to be stored based on the key value and the data length.

[0167] Step S205, obtaining the current position value corresponding to each sub-data in the data to be stored; determining the position factor corresponding to each sub-data according to the current position value, offset and confusion factor corresponding to each sub-data, and determining the hash bit corresponding to each sub-data according to the target hash value and the current position value.

[0168] Step S206: Determine the initial check code corresponding to each sub-data according to each sub-data, the position factor and the hash bit.

[0169] Step S207 : updating the initial check code corresponding to each sub-data according to the current position value, confusion factor and data length corresponding to each sub-data to obtain a processed check code corresponding to each sub-data.

[0170] Step S208 : determining an updated check code corresponding to each sub-data according to the processed check code and the initial check code corresponding to each sub-data.

[0171] Step S209 : Combining the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored.

[0172] In step S210 , the data to be stored and the target check code corresponding to the data to be stored are stored in a storage table of the electric energy meter according to the row number value.

[0173] In the data storage method of the above-mentioned electric energy meter, when storing the data of the electric energy meter, the row number value is first determined based on the data to be stored and the corresponding secret key value is generated, so that the secret key is dynamically associated with the storage location, and then the target hash value is calculated in combination with the secret key value and the data length to ensure that the hash value depends on both the data content and the storage environment, and then the sub-data initial check code is generated using the secret key value and the hash value, and then the check code is updated in combination with the data length to form a double check, and finally the updated check code is combined to obtain the target check code, which is stored synchronously with the data; this method of deeply coupling the storage location, data length and encryption check can effectively prevent data tampering, forgery of storage location and unauthorized access, which is conducive to improving the security of data storage; moreover, the above process avoids the defect that when the storage address is prone to change during program upgrades, it is easy to cause instability such as data dislocation, resulting in low security of data storage, thereby further improving the security of data storage.

[0174] In an exemplary embodiment, in order to more clearly illustrate the data storage method of the electric energy meter provided in the embodiment of the present application, the data storage method of the electric energy meter is specifically described below using a specific embodiment. In one embodiment, the present application also provides another data storage method of the electric energy meter. Specifically, it includes the following contents:

[0175] This embodiment provides a data storage table for an electric energy meter, as shown in Table 1:

[0176] Table 1 Data storage table of electric energy meter

[0177]

[0178] Specifically include the following:

[0179] 1. Create a storage table inside the electricity meter. The table has n rows. Each row includes data identifier, RAM address, EEPROM (Electrically Erasable Programmable Read-Only Memory) address, and length.

[0180] 2. The content in the RAM address includes data content + check code; the content in the EEPROM address includes data content + check code.

[0181] 3. The length includes the length of the data content + the length of the check code.

[0182] 4. According to the standard protocol of the electricity meter, each data has a data identifier. When an external device reads the data inside the electricity meter through the data identifier, the data table is queried through the data identifier. When the data identifiers are consistent, the query is completed, and the row number of the data identifier is also known.

[0183] 5. According to the RAM address and length of the row number, take out the data content of the corresponding length + check code from the RAM address.

[0184] 6. According to the row number and data content, a new check code calculation method is used to calculate the check code. If the calculated check code is consistent with the check code taken from the RAM address, the data is considered correct and returned to the external device.

[0185] 7. If the calculated check code is inconsistent with the check code retrieved from RAM, the data is considered incorrect. According to the EEPROM address and length of the row number, the data content + check code of the corresponding length is retrieved from the EEPROM.

[0186] 8. Calculate the check code based on the row number and data content. If the calculated check code is consistent with the check code retrieved from the EEPROM, the data is considered correct and returned to the external device. Otherwise, an error response is sent to the external device. Because in most cases, the data in the RAM is correct, there is no need to read the data in the EEPROM, thus ensuring access efficiency when reading data.

[0187] 9. When the external device sets the data inside the electric energy meter through the data identifier, the data table is queried through the data identifier. When the data identifiers are consistent, the query is completed and the row number of the data is also known.

[0188] 10. According to the row number, RAM address and length of the data, a new check code calculation method is used to calculate the check code, and the data together with the check code are written to the RAM address and the EEPROM address.

[0189] like Figure 3 As shown, the new check code calculation method is specifically as follows:

[0190] S1. Generate secret keys: The row number is used through a nonlinear function to generate multiple secret keys (including multiplier, offset, confusion factor, and seed value) for calculation of the checksum. Different row numbers generate different secret keys, ensuring the sensitivity of the row number.

[0191] S1.1. Calculate the multiplier (8 bits long): Use the row number, prime number 17, and constant 37 to perform a nonlinear transformation and force it into an unsigned 8-bit format (uint8_t):

[0192] , formula (1)

[0193] Prime numbers are chosen for multiplication because they are coprime with most numbers, which can reduce the probability of data conflicts or uneven data distribution. Other prime numbers can also be used instead. Constants are added to enhance nonlinear transformations and avoid direct mapping of inputs and outputs. Other constants can also be used instead (the same below).

[0194] S1.2. Calculate the offset (8 bits in length): Perform a nonlinear transformation using the row number, prime number 23, and constant 53. To enhance sensitivity to the row number and reduce conflicts in the checksum, the transformed result is modulo the prime number 251 to obtain the offset. This is generated in a different data space from the multiplier:

[0195] , formula (2)

[0196] S1.3. Calculate the confusion factor (mix_factor, 8 bits): XOR the multiplier and the offset, AND the row number with the hexadecimal number 0xff to obtain the lower 8 bits of the row number, and OR the two results to increase the randomness of the confusion factor:

[0197] , formula (3)

[0198] The ^(XOR) operation is chosen because the XOR operation is highly sensitive to input changes and can also eliminate linear relationships. It is combined with the OR and AND operations to enhance the nonlinear characteristics of the secret key (the same below).

[0199] S1.4. Calculate the seed value (seed, 32 bits): To integrate multi-source information and maximize the information entropy of the row number and intermediate parameters, the seed value is designed to be obtained by the following algorithm: bits 31-16 of the seed value are generated by shifting the row number left by 16 bits, bits 15-8 are generated by shifting the confusion factor left by 8 bits, and bits 7-0 are generated by XORing the offset and the multiplier:

[0200] , formula (4)

[0201] Using the seed value to participate in the subsequent checksum calculation can further improve the sensitivity of the row number and ultimately generate a highly sensitive checksum.

[0202] S2. Hash value (32-bit) calculation: Calculate the data content byte by byte to generate a hash value.

[0203] S2.1. Initialize the hash value to the seed value:

[0204] , formula (5)

[0205] S2.2. Assume that the data content for which the checksum is to be calculated is an array data[Len] of length Len, data[0] represents the 0th data in the array, data[i] represents the ith data in the array, and data[Len-1] represents the last data in the array. i is the current loop value, starting from 0 and changing to Len-1, looping Len times. In the i-th pass, data[i] is first XORed with the product of the hash value and the multiplier, and then XORed with the hash value shifted right by 13 bits to calculate the hash value. The hash value is then shifted right by 27 bits or the previous hash value is shifted left by 5 bits to calculate the new hash value. The details are as follows:

[0206] , formula (6)

[0207] , formula (7)

[0208] S3. Calculate the preliminary checksum: Calculate a preliminary checksum of equal length based on the data content. The specific steps include calculating the position factor (pos_factor, 32 bits), calculating the hash bit (hash_bit, 8 bits), and calculating a preliminary checksum checksum[Len] of equal length to the data data[Len], looping Len times. The position factor is used to convert the row number information and position information into a dynamic offset to ensure the position sensitivity and row number dependency of the checksum. The calculation method is: multiply the current loop value i by the confusion factor and then add the offset, and then take the remainder of the result with 256 to calculate the position factor. The hash bit is used to inject the global characteristics of the data into the checksum of each byte to achieve avalanche effect and collision resistance. The calculation method is: shift the hash value right by the current loop value i bits, and then perform an AND operation with 0xff to obtain the hash bit. The calculation method of the preliminary checksum is: first perform an XOR operation on the current i-th data data[i] and the hash bit, and then perform an XOR operation on the result with the position factor to obtain the i-th preliminary checksum checksum[i].

[0209] , formula (8)

[0210] , formula (9)

[0211] , formula (10)

[0212] After the loop is completed, a preliminary checksum [Len] with a length of Len is generated.

[0213] S4. Calculate the final checksum: After calculating the preliminary checksum, to further enhance its randomness and diffusion, even small changes in the data will cause a dramatic change in the checksum, thus reducing the false positive rate. An additional obfuscation step is performed to calculate the final checksum [Len]. The calculation method is: add the obfuscation factor to the current loop value i, then take the modulus of the data length. The result is the checksum of that number, and perform an XOR operation with the i-th checksum. The result is the i-th final checksum [i].

[0214] , formula (11)

[0215] After the loop is completed, the final checksum [Len] with a length of Len is generated.

[0216] For example: Assume that there are two arrays with a length of 4, the data is the same, and the data format is hexadecimal, both data[4]={0x12, 0x34, 0x56, 0x78}, which are respectively in the 1st and 2nd rows of the storage table. According to the above check code calculation method, the check code of the array in the 1st row is calculated to be {0x2f, 0x2f, 0xef, 0x33}, and the check code of the array in the 2nd row is {0x3e, 0x46, 0xe1, 0x8c}. It can be seen that the check codes calculated for the same data in different row numbers are completely different, and it is extremely sensitive to the row number. It can effectively avoid the data shifting during the upgrade or external interference of the electricity meter, and the data with check codes in other row numbers is shifted to this row number and missed detection occurs.

[0217] Another example: suppose the data length is 3 and the array data[3]={0x11, 0x22, 0x33}. In the 5th row of the storage table, according to the above check code calculation method, the calculated check code is {0x26, 0x98, 0x75}. Suppose the data of the array has an accident, and the first data has a slight change from 0x11 to 0x12, that is, data[3]={0x12, 0x22, 0x33}. According to the above check code calculation method, the calculated check code is {0xd7, 0x5d, 0x5f}. It can be seen that if only a certain data changes slightly, the generated check code will have an avalanche effect. The calculation of the check code can clearly determine whether the data is wrong.

[0218] Another example: the array data[1]={0xaa} with a data length of 1, in the first row of the storage table, according to the above check code calculation method, the calculated check code is {0x5c}, the array data[8]={0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88} with a data length of 8, in the first row of the storage table, according to the above check code calculation method, the calculated check code is {0x3a, 0x7b, 0x9c, 0x2d, 0x6e, 0x1f, 0x40, 0x51}. It can be seen that the length of the check code is equal to the data length, which can effectively reduce the possibility of false detection when long data uses traditional CRC16 check, when the data content is different but the CRC16 check code is the same.

[0219] In the above embodiment, when storing the data of the electric energy meter, the row number value is first determined based on the data to be stored and the corresponding secret key value is generated, so that the secret key is dynamically associated with the storage location, and then the target hash value is calculated in combination with the secret key value and the data length to ensure that the hash value depends on both the data content and the storage environment, and then the sub-data initial check code is generated using the secret key value and the hash value, and then the check code is updated in combination with the data length to form a double check, and finally the updated check code is combined to obtain the target check code, which is stored synchronously with the data; this method of deeply coupling the storage location, data length and encryption check can effectively prevent data tampering, forgery of storage location and unauthorized access, which is conducive to improving the security of data storage; moreover, the above process avoids the defect that when the storage address is prone to change during program upgrades, unstable phenomena such as data dislocation are easily caused, resulting in low security of data storage, thereby further improving the security of data storage.

[0220] It should be understood that, although the steps in the flowcharts of the above embodiments are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the flowcharts of the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily to be performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0221] Based on the same inventive concept, an embodiment of the present application further provides a data storage device for an electric energy meter for implementing the aforementioned data storage method for an electric energy meter. The implementation solution provided by this device is similar to the implementation solution described in the aforementioned method. Therefore, the specific limitations of the one or more embodiments of the data storage device for an electric energy meter provided below can be found in the above-mentioned limitations of the data storage method for an electric energy meter, and will not be repeated here.

[0222] In an exemplary embodiment, Figure 4 As shown, a data storage device for an electric energy meter is provided, comprising: a row number value determination module 401, a secret key value determination module 402, a hash value determination module 403, a check code determination module 404, a check code update module 405, a check code combination module 406, and a data storage module 407, wherein:

[0223] The row number value determination module 401 is used to obtain the data to be stored associated with the electric energy meter, and determine the row number value corresponding to the data to be stored in the storage table of the electric energy meter.

[0224] The key value determination module 402 is used to determine the key value corresponding to the data to be stored according to the row number value.

[0225] The hash value determination module 403 is used to obtain the data length corresponding to the data to be stored, and determine the target hash value corresponding to the data to be stored according to the secret key value and the data length.

[0226] The check code determination module 404 is configured to determine an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value.

[0227] The check code updating module 405 is used to update the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain the updated check code corresponding to each sub-data.

[0228] The check code combination module 406 is used to combine the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored.

[0229] The data storage module 407 is used to store the data to be stored and the target check code corresponding to the data to be stored into the storage table of the electric energy meter according to the row number value.

[0230] In an exemplary embodiment, the key value determination module 402 is further configured to perform a first nonlinear transformation on the row number value to obtain a multiplier value corresponding to the data to be stored, and perform a second nonlinear transformation on the row number value to obtain an offset corresponding to the data to be stored; determine an obfuscation factor corresponding to the data to be stored based on the row number value, the multiplier value, and the offset; determine a seed value corresponding to the data to be stored based on the row number value, the multiplier value, the offset, and the obfuscation factor; and use the multiplier value, the offset, the obfuscation factor, and the seed value as the key value corresponding to the data to be stored.

[0231] In an exemplary embodiment, the hash value determination module 403 is further used to use the seed value as the initial hash value corresponding to the data to be stored; update the initial hash value to obtain the updated hash value corresponding to the data to be stored; obtain the number of updates corresponding to the updated hash value, and use the updated hash value as the new initial hash value, and jump to the step of updating the initial hash value to obtain the updated hash value corresponding to the data to be stored, until the number of updates meets the preset number of updates; the preset number of updates is determined by the data length; and the updated hash value that meets the preset number of updates is used as the target hash value corresponding to the data to be stored.

[0232] In an exemplary embodiment, the hash value determination module 403 is further configured to update the initial hash value according to each sub-data and the multiplier value to obtain a processed hash value corresponding to the data to be stored; and perform cyclic shift processing on the processed hash value to obtain an updated hash value corresponding to the data to be stored.

[0233] In an exemplary embodiment, the check code determination module 404 is further used to obtain the current position value corresponding to each sub-data in the data to be stored; determine the position factor corresponding to each sub-data based on the current position value, offset and confusion factor corresponding to each sub-data, and determine the hash bit corresponding to each sub-data based on the target hash value and the current position value; and determine the initial check code corresponding to each sub-data based on each sub-data, the position factor and the hash bit.

[0234] In an exemplary embodiment, the check code update module 405 is further configured to update the initial check code corresponding to each sub-data based on the current position value, confusion factor, and data length corresponding to each sub-data to obtain a processed check code corresponding to each sub-data; and determine the updated check code corresponding to each sub-data based on the processed check code and the initial check code corresponding to each sub-data.

[0235] Each module in the data storage device of the aforementioned electric energy meter can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0236] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data such as row number values, multiplier values, offsets and confusion factors. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data storage method for an electric energy meter is implemented.

[0237] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0238] In an exemplary embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.

[0239] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0240] In an exemplary embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0241] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), data processing logic devices based on quantum computing, and the like.

[0242] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0243] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A data storage method for an electric energy meter, characterized in that: The method comprises: Acquire data to be stored associated with the electric energy meter, and determine a row number value corresponding to the data to be stored in a storage table of the electric energy meter; Determining a secret key value corresponding to the data to be stored according to the row number value; Obtaining the data length corresponding to the data to be stored, and determining the target hash value corresponding to the data to be stored based on the secret key value and the data length; Determining an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value; updating the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain an updated check code corresponding to each sub-data; Combining the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored; According to the row number value, the data to be stored and the target check code corresponding to the data to be stored are stored in the storage table of the electric energy meter.

2. The method according to claim 1, characterized in that Determining the key value corresponding to the data to be stored according to the row number value includes: Performing a first nonlinear transformation on the row number value to obtain a multiplier value corresponding to the data to be stored, and performing a second nonlinear transformation on the row number value to obtain an offset corresponding to the data to be stored; Determining, according to the row number value, the multiplier value, and the offset, a confusion factor corresponding to the data to be stored; Determining a seed value corresponding to the data to be stored according to the row number value, the multiplier value, the offset, and the confusion factor; The multiplier value, the offset, the confusion factor, and the seed value are all used as the secret key value corresponding to the data to be stored.

3. The method according to claim 2, characterized in that Determining a target hash value corresponding to the data to be stored according to the secret key value and the data length includes: Using the seed value as the initial hash value corresponding to the data to be stored; Updating the initial hash value to obtain an updated hash value corresponding to the data to be stored; Obtaining the update number corresponding to the updated hash value, using the updated hash value as a new initial hash value, and jumping to the step of updating the initial hash value to obtain the updated hash value corresponding to the data to be stored, until the update number meets a preset update number; the preset update number is determined by the data length; The updated hash value that satisfies the preset update times is used as the target hash value corresponding to the data to be stored.

4. The method according to claim 3, characterized in that The updating of the initial hash value to obtain an updated hash value corresponding to the data to be stored includes: updating the initial hash value according to each sub-data and the multiplier value to obtain a processed hash value corresponding to the data to be stored; Performing a cyclic shift process on the processed hash value to obtain an updated hash value corresponding to the data to be stored.

5. The method according to claim 2, characterized in that The determining, based on the secret key value and the target hash value, an initial check code corresponding to each sub-data in the data to be stored includes: Obtaining a current position value corresponding to each sub-data in the data to be stored; Determining a position factor corresponding to each sub-data according to the current position value corresponding to each sub-data, the offset, and the confusion factor, and determining a hash bit corresponding to each sub-data according to the target hash value and the current position value; An initial check code corresponding to each sub-data is determined according to each sub-data, the position factor and the hash bit.

6. The method according to claim 5, characterized in that The updating of the initial check code corresponding to each sub-data according to the secret key value and the data length to obtain the updated check code corresponding to each sub-data includes: updating the initial check code corresponding to each sub-data according to the current position value corresponding to each sub-data, the confusion factor, and the data length, to obtain a processed check code corresponding to each sub-data; An updated check code corresponding to each sub-data is determined according to the processed check code and the initial check code corresponding to each sub-data.

7. A data storage device for an electric energy meter, characterized in that: The device comprises: a row number value determination module, configured to obtain data to be stored associated with the electric energy meter, and determine a row number value corresponding to the data to be stored in a storage table of the electric energy meter; A key value determination module, configured to determine a key value corresponding to the data to be stored according to the row number value; A hash value determination module is used to obtain the data length corresponding to the data to be stored, and determine the target hash value corresponding to the data to be stored according to the secret key value and the data length; a check code determination module, configured to determine an initial check code corresponding to each sub-data in the data to be stored according to the secret key value and the target hash value; a check code updating module, configured to update the initial check code corresponding to each sub-data according to the secret key value and the data length, to obtain an updated check code corresponding to each sub-data; a check code combination module, configured to combine the updated check codes corresponding to each sub-data to obtain a target check code corresponding to the data to be stored; The data storage module is used to store the data to be stored and the target check code corresponding to the data to be stored in the storage table of the electric energy meter according to the row number value.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Client verification method and apparatus

    CN108259490A

  • Data processing method, data processing device, electronic equipment and medium

    CN112765642A

  • Method, device and equipment for managing data based on hash table and storage medium

    CN114328503A