Data storage methods, devices, computer equipment, storage media, and computer program products for electricity meters
Patent Information
- Application Number
- CN202510802543.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2045-06-16
AI Technical Summary
[0003]传统技术中,在对电能表的数据进行存储时,一般采用RAM(Random AccessMemory,随机存取存储器)存储的方式;但是,这种方式在程序升级时存储地址易发生变化的情况下,容易造成数据错位等不稳定现象,导致数据存储的安全性较低
[0063]将所述每个子数据对应的更新后校验码进行组合处理,得到所述待存储数据对应的目标校验码;
Smart Images

Figure CN120669919B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of power grid technology, and in particular to a data storage method, apparatus, computer equipment, computer-readable storage medium, and computer program product for an electricity meter. Background Technology
[0002] Currently, electricity meters are a crucial component of the power system, and their data storage performance and reliability are of great significance to the operation and management of the power system. Therefore, how to securely store electricity meter data is of paramount importance.
[0003] In traditional technology, RAM (Random Access Memory) is generally used to store data in electricity meters. However, this method is prone to data misalignment and other instability when the storage address changes during program upgrades, resulting in low data storage security. Summary of the Invention
[0004] Therefore, it is necessary to provide a data storage method, apparatus, computer equipment, computer-readable storage medium, and computer program product for an electricity meter that can improve the security of data storage, in order to address the aforementioned technical problems.
[0005] In a first aspect, this application provides a data storage method for an electricity meter, comprising:
[0006] Obtain the data to be stored associated with the electricity meter, and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter;
[0007] Based on the row number value, the key value corresponding to the data to be stored is determined;
[0008] 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;
[0009] Based on the key value and the target hash value, the initial checksum corresponding to each sub-data in the data to be stored is determined;
[0010] Based on the key value and the data length, the initial checksum corresponding to each sub-data is updated to obtain the updated checksum corresponding to each sub-data.
[0011] The updated check codes corresponding to each sub-data are combined to obtain the 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 electricity meter.
[0013] In one embodiment, determining the key value corresponding to the data to be stored based on the row number value includes:
[0014] The row number value is subjected to a first nonlinear transformation to obtain the multiplier value corresponding to the data to be stored, and the row number value is subjected to a second nonlinear transformation to obtain the offset value corresponding to the data to be stored.
[0015] The confusion factor corresponding to the data to be stored is determined based on the row number value, the multiplier value, and the offset.
[0016] The seed value corresponding to the data to be stored is determined based on the row number value, the multiplier value, the offset, and the confusion factor.
[0017] The multiplier, the offset, the confusion factor, and the seed value are all used as the key value corresponding to the data to be stored.
[0018] In one embodiment, determining the target hash value corresponding to the data to be stored based on the key value and the data length includes:
[0019] Use the seed value as the initial hash value corresponding to the data to be stored;
[0020] The initial hash value is updated to obtain the updated hash value corresponding to the data to be stored;
[0021] The process involves obtaining the update count corresponding to the updated hash value, using the updated hash value as the new initial hash value, and then proceeding 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 count meets a preset update count; the preset update count is determined by the data length.
[0022] The updated hash value that meets the preset number of updates will be used as the target hash value corresponding to the data to be stored.
[0023] In one embodiment, updating the initial hash value to obtain the updated hash value corresponding to the data to be stored includes:
[0024] The initial hash value is updated based on each sub-data and the multiplier value to obtain the processed hash value corresponding to the data to be stored.
[0025] The processed hash value is cyclically shifted to obtain the updated hash value corresponding to the data to be stored.
[0026] In one embodiment, determining the initial checksum corresponding to each sub-data item in the data to be stored based on the key value and the target hash value includes:
[0027] Obtain the current position value corresponding to each sub-data in the data to be stored;
[0028] Based on the current position value corresponding to each sub-data, the offset, and the confusion factor, the position factor corresponding to each sub-data is determined, and based on the target hash value and the current position value, the hash bit corresponding to each sub-data is determined.
[0029] Based on each sub-data, the position factor, and the hash bit, the initial checksum corresponding to each sub-data is determined.
[0030] In one embodiment, the step of updating the initial checksum corresponding to each sub-data piece based on the key value and the data length to obtain the updated checksum corresponding to each sub-data piece includes:
[0031] Based on the current position value, the confusion factor, and the data length of each sub-data, the initial check code corresponding to each sub-data is updated to obtain the processed check code corresponding to each sub-data.
[0032] Based on the processed checksum and the initial checksum corresponding to each sub-data, the updated checksum corresponding to each sub-data is determined.
[0033] Secondly, this application also provides a data storage device for an electricity meter, comprising:
[0034] The row number value determination module is used to obtain the data to be stored associated with the electricity meter and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter.
[0035] The key value determination module is used to determine the key value corresponding to the data to be stored based on the row number value.
[0036] The 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 based on the key value and the data length.
[0037] The verification code determination module is used to determine the initial verification code corresponding to each sub-data in the data to be stored based on the key value and the target hash value.
[0038] The verification code update module is used to update the initial verification code corresponding to each sub-data according to the key value and the data length, so as to obtain the updated verification code corresponding to each sub-data.
[0039] The check code combination module is used to combine the updated check codes corresponding to each sub-data to obtain the 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 into the storage table of the electricity meter according to the row number value.
[0041] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0042] Obtain the data to be stored associated with the electricity meter, and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter;
[0043] Based on the row number value, the key value corresponding to the data to be stored is determined;
[0044] 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;
[0045] Based on the key value and the target hash value, the initial checksum corresponding to each sub-data in the data to be stored is determined;
[0046] Based on the key value and the data length, the initial checksum corresponding to each sub-data is updated to obtain the updated checksum corresponding to each sub-data.
[0047] The updated check codes corresponding to each sub-data are combined to obtain the 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 electricity meter.
[0049] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0050] Obtain the data to be stored associated with the electricity meter, and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter;
[0051] Based on the row number value, the key value corresponding to the data to be stored is determined;
[0052] 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;
[0053] Based on the key value and the target hash value, the initial checksum corresponding to each sub-data in the data to be stored is determined;
[0054] Based on the key value and the data length, the initial checksum corresponding to each sub-data is updated to obtain the updated checksum corresponding to each sub-data.
[0055] The updated check codes corresponding to each sub-data are combined to obtain the 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 electricity meter.
[0057] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0058] Obtain the data to be stored associated with the electricity meter, and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter;
[0059] Based on the row number value, the key value corresponding to the data to be stored is determined;
[0060] 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;
[0061] Based on the key value and the target hash value, the initial checksum corresponding to each sub-data in the data to be stored is determined;
[0062] Based on the key value and the data length, the initial checksum corresponding to each sub-data is updated to obtain the updated checksum corresponding to each sub-data.
[0063] The updated check codes corresponding to each sub-data are combined to obtain the 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 electricity meter.
[0065] The aforementioned data storage method, device, computer equipment, storage medium, and computer program product for electricity meters first acquire the data to be stored associated with the electricity meter and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter. Then, based on the row number value, determine the key value corresponding to the data to be stored and acquire the data length corresponding to the data to be stored. Based on the key value and the data length, determine the target hash value corresponding to the data to be stored. Next, based on the key value and the target hash value, determine the initial checksum corresponding to each sub-data in the data to be stored. Based on the key value and the data length, update the initial checksum corresponding to each sub-data to obtain the updated checksum corresponding to each sub-data. Then, combine the updated checksums corresponding to each sub-data to obtain the target checksum corresponding to the data to be stored. Finally, according to the row number value, store the data to be stored and the target checksum corresponding to the data to be stored in the storage table of the electricity meter. In this way, when storing data from an electricity meter, the row number is first determined based on the data to be stored, and a corresponding key value is generated, dynamically associating the key with the storage location. Then, the target hash value is calculated by combining the key value and the data length, ensuring that the hash value depends on both the data content and the storage environment. Next, the initial checksum of the sub-data is generated using the key value and the hash value, and then the checksum is updated by combining it with the data length, forming a double check. Finally, the updated checksum is combined to obtain the target checksum, which is stored synchronously with the data. This method of deeply coupling storage location, data length, and encryption verification can effectively prevent data tampering, forgery of storage location, and unauthorized access, which is beneficial to improving the security of data storage. Moreover, the above process avoids the instability caused by data misalignment when the storage address changes during program upgrades, which leads to lower data storage security, further improving the security of data storage. Attached Figure Description
[0066] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0067] Figure 1 This is a flowchart illustrating a data storage method for an electricity meter in one embodiment;
[0068] Figure 2 This is a flowchart illustrating the data storage method of an electricity meter in another embodiment;
[0069] Figure 3 This is a flowchart illustrating a checksum calculation method in one embodiment;
[0070] Figure 4 This is a structural block diagram of the data storage device of an electricity meter in one embodiment;
[0071] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0072] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of 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, data stored, data displayed, 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 the relevant data must comply with relevant regulations.
[0074] In one exemplary embodiment, such as Figure 1 As shown, a data storage method for an electricity meter is provided. This embodiment illustrates the application of this method to a server. It is understood that this method can also be applied to a terminal, or to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, and tablets; the server can be a standalone server or a server cluster composed of multiple servers. In this embodiment, the method includes the following steps:
[0075] Step S101: Obtain the data to be stored associated with the electricity meter and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter.
[0076] Among them, an electricity meter refers to an instrument used to measure electrical energy.
[0077] Among them, the data to be stored refers to the data that needs to be stored.
[0078] Among them, the storage table refers to the data storage table established inside the electricity meter.
[0079] The row number value indicates the row position number of the data to be stored in the built-in storage table of the electricity meter.
[0080] For example, the server obtains electrical parameter data (such as voltage data, current data, etc.), status data (such as operating status data, hardware status data, etc.), and auxiliary data (such as timestamps, etc.) associated with the electricity meter through the data interface of the electricity 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 electricity meter. Then, the server combines the preprocessed electrical parameter data, preprocessed status data, and preprocessed auxiliary data corresponding to the electricity meter according to a preset combination method to obtain the data to be stored associated with the electricity meter. Finally, the server determines the row number value of the data to be stored in the storage table of the electricity meter according to the storage order of the data to be stored.
[0081] Step S102: Determine the key value corresponding to the data to be stored based on the row number value.
[0082] The key value includes at least the multiplier, offset, obfuscation factor, and seed value corresponding to the data to be stored.
[0083] For example, the server queries the correspondence between the row number value and the key value based on the row number value to obtain 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 key value and the data length.
[0085] The data length is used to represent the number of bytes of data to be stored.
[0086] The target hash value is used to represent the unique digest value corresponding to the data to be stored.
[0087] For example, 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 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 performs fusion processing on 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: Determine the initial checksum corresponding to each sub-data in the data to be stored based on the key value and the target hash value.
[0089] Here, sub-data refers to the smallest data unit in the data to be stored.
[0090] The initial checksum refers to the checksum corresponding to each sub-data in the data to be stored, determined based on the key value and the target hash value.
[0091] For example, the server performs verification processing on the target hash value to obtain the verification result of the target hash value; if the verification result of the target hash value indicates that the target hash value is passed, the server determines the check code corresponding to each sub-data in the data to be stored based on the key value and the target hash value, and uses it as the initial check code corresponding to each sub-data in the data to be stored.
[0092] Step S105: Based on the key value and data length, update the initial checksum corresponding to each sub-data to obtain the updated checksum corresponding to each sub-data.
[0093] The updated checksum refers to the checksum obtained by updating the initial checksum corresponding to each sub-data based on the key value and data length.
[0094] For example, the server extracts the key key value from the key value; then, the server updates the initial checksum corresponding to each sub-data according to the key key value and the data length, and obtains the updated checksum corresponding to each sub-data.
[0095] Step S106: Combine the updated check codes corresponding to each sub-data to obtain the target check code corresponding to the data to be stored.
[0096] The target check code refers to the check code obtained by combining the updated check codes corresponding to each sub-data.
[0097] For example, the server combines the updated checksums corresponding to each sub-data according to the current position value of each sub-data to obtain the combined checksum, and uses the combined checksum as the target checksum corresponding to the data to be stored.
[0098] Step S107: Store the data to be stored and the corresponding target verification code of the data to be stored into the storage table of the electricity meter according to the row number value.
[0099] For example, 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 the sub-storage table corresponding to the row number value in the storage table of the electricity meter.
[0100] In the above-mentioned data storage method for electricity meters, the data to be stored associated with the electricity meter is first obtained, and the row number value corresponding to the data to be stored in the storage table of the electricity meter is determined. Then, based on the row number value, the key value corresponding to the data to be stored is determined, and the data length corresponding to the data to be stored is obtained. Based on the key value and the data length, the target hash value corresponding to the data to be stored is determined. Next, based on the key value and the target hash value, the initial check code corresponding to each sub-data in the data to be stored is determined, and based on the 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. Then, the updated check codes corresponding to each sub-data are combined to obtain the target check code corresponding to the data to be stored. 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 electricity meter. In this way, when storing data from an electricity meter, the row number is first determined based on the data to be stored, and a corresponding key value is generated, dynamically associating the key with the storage location. Then, the target hash value is calculated by combining the key value and the data length, ensuring that the hash value depends on both the data content and the storage environment. Next, the initial checksum of the sub-data is generated using the key value and the hash value, and then the checksum is updated by combining it with the data length, forming a double check. Finally, the updated checksum is combined to obtain the target checksum, which is stored synchronously with the data. This method of deeply coupling storage location, data length, and encryption verification can effectively prevent data tampering, forgery of storage location, and unauthorized access, which is beneficial to improving the security of data storage. Moreover, the above process avoids the instability caused by data misalignment when the storage address changes during program upgrades, which leads to lower data storage security, further improving the security of data storage.
[0101] In an exemplary embodiment, step S102, which determines the key value corresponding to the data to be stored based on the row number value, specifically includes the following: performing a first nonlinear transformation on the row number value to obtain the multiplier value corresponding to the data to be stored, and performing a second nonlinear transformation on the row number value to obtain the offset value corresponding to the data to be stored; determining the obfuscation factor corresponding to the data to be stored based on the row number value, the multiplier value, and the offset value; determining the seed value corresponding to the data to be stored based on the row number value, the multiplier value, the offset value, and the obfuscation factor; and using the multiplier value, the offset value, the obfuscation factor, and the seed value as the key value corresponding to the data to be stored.
[0102] The first nonlinear transformation process refers to the operation of mapping the row number value to a multiplier value through a nonlinear function. In practical scenarios, the first nonlinear transformation process refers to the operation of performing a nonlinear transformation on the row number value with the prime number 17 and the constant 37.
[0103] Here, the multiplier value refers to the multiplier factor corresponding to the data to be stored.
[0104] The second nonlinear transformation process refers to the operation of mapping the row number value to an offset using a nonlinear function. In practical scenarios, the first nonlinear transformation process refers to the operation of performing a nonlinear transformation on the row number value with the prime number 23 and the constant 53.
[0105] Here, 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, multiplier value, offset, and confusion factor.
[0108] For example, the server performs a non-linear transformation on the row number value with 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. It also performs a non-linear transformation on the row number value with the prime number 23 and the constant 53, takes the modulo of the transformed result with the prime number 251, and converts the modulo result into an unsigned 8-bit format to obtain the offset value corresponding to the data to be stored. Next, the server performs an XOR operation on the multiplier and the offset value to obtain the XOR result, and performs a AND operation on the row number with the hexadecimal number 0xff to obtain the lower 8 bits of the row number. The XOR operation result is ORed with the lower 8 bits of the row number to obtain the obfuscation factor corresponding to the data to be stored. Then, the server inputs the row number value, multiplier value, offset, and obfuscation factor into the seed value prediction model (algorithm) to obtain the seed value corresponding to the data to be stored. The seed value can be calculated as follows: bits 31 to 16 of the seed value are generated by left-shifting the row number by 16 bits, bits 15 to 8 are generated by left-shifting the obfuscation factor by 8 bits, and bits 7 to 0 are generated by XORing the offset and multiplier. Then, the server uses the multiplier value, offset, obfuscation factor, and seed value as the key value corresponding to the data to be stored.
[0109] For example, the multiplier value can be calculated using the following formula:
[0110] Equation (1)
[0111] Among them, multiplier refers to the multiplier value, uint8_t (unsigned 8-bit integer type) refers to the unsigned 8-bit format conversion processing, and row refers to the row number.
[0112] For example, the offset can be calculated using the following formula:
[0113] Equation (2)
[0114] Here, offset refers to the offset amount.
[0115] For example, the confusion factor can be calculated using the following formula:
[0116] Equation (3)
[0117] Here, mix_factor refers to the confusion factor.
[0118] For example, the seed value can be calculated using the following formula:
[0119] Equation (4)
[0120] Here, seed refers to the seed value.
[0121] In this embodiment, the complexity of the key space and its resistance to exhaustive search are enhanced by combining and calculating multiple levels of parameters. Even if a certain level of parameter is leaked, it is difficult to reverse-engineer the overall key. At the same time, it dynamically adapts to the key requirements of different row numbers, providing fine-grained and highly secure key management for electricity meter data storage, and ensuring the integrity and confidentiality of data in storage and transmission.
[0122] In an exemplary embodiment, step S103, which determines the target hash value corresponding to the data to be stored based on the key value and the data length, specifically includes the following: 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 update count 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 update count meets the preset update count; the preset update count is determined by the data length; and the updated hash value that meets the preset update count 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 the hash value obtained by updating the initial hash value.
[0125] The update count refers to the number of iterations performed on the initial hash value.
[0126] The preset update count refers to the number of updates set in advance, which is determined by the data length. For example, if the data length is 5, the preset update count is 5.
[0127] For example, 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; finally, 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] Equation (5)
[0130] In this embodiment, by utilizing the correlation mechanism between data length and update frequency, the hash calculation complexity is dynamically adjusted with the data scale, providing high-strength hash protection that is deeply bound to data characteristics for the data to be stored, ensuring the uniqueness and anti-attack properties of the target hash value.
[0131] In an exemplary embodiment, updating the initial hash value to obtain the updated hash value corresponding to the data to be stored specifically includes the following: updating the initial hash value according to each sub-data and multiplier value to obtain the processed hash value corresponding to the data to be stored; and performing a cyclic shift operation on the processed hash value to obtain the updated hash value corresponding to the data to be stored.
[0132] The processed hash value refers to the hash value obtained by updating the initial hash value based on each sub-data and multiplier value.
[0133] For example, 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 performs another XOR operation on the result of the XOR operation with the initial hash value shifted 13 bits to the right to obtain the processed hash value corresponding to the data to be stored; then, the server performs an OR operation on the processed hash value shifted 27 bits to the right and the processed hash value shifted 5 bits to the left 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] Equation (6)
[0136] Here, data[i] refers to each sub-data.
[0137] For example, the updated hash value can be calculated using the following formula:
[0138] Equation (7)
[0139] In this embodiment, by utilizing the linkage update of multiplier values and sub-data, hash calculation is integrated with data characteristics and nonlinear transformation factors, enhancing the binding degree between hash values and original data, avoiding hash collisions caused by changes in single data or multiplier values, 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, step S104 above, which determines the initial checksum corresponding to each sub-data in the data to be stored based on the key value and the target hash value, specifically includes the following: 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 obfuscation factor corresponding to each sub-data; determining the hash bit corresponding to each sub-data based on the target hash value and the current position value; and determining the initial checksum corresponding to each sub-data based on each sub-data, the position factor, and the hash bit.
[0141] The current position value represents the relative position of each sub-data item within the data to be stored. In practical scenarios, the current position value is also called the current loop value i.
[0142] The position factor refers to the nonlinear transformation value calculated using the current position value, offset, and confusion factor of each sub-data.
[0143] Here, a hash bit refers to a specific combination of bits extracted from the target hash value that is related to the current position value.
[0144] For example, 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 obfuscation factor and adds the offset, and takes the remainder of the result divided by 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 result with the position factor to obtain the initial checksum corresponding to each sub-data.
[0145] For example, the location factor can be calculated using the following formula:
[0146] Equation (8)
[0147] Here, pos_factor refers to the position factor.
[0148] For example, the hash bit can be calculated using the following formula:
[0149] Equation (9)
[0150] Here, hash_bit refers to the hash bit.
[0151] For example, the initial checksum can be calculated using the following formula:
[0152] Equation (10)
[0153] Here, checksum[i] refers to the initial checksum corresponding to the i-th sub-data in the data to be stored.
[0154] In this embodiment, an initial verification code is generated by fusing data location features, dynamic key parameters, and global hash characteristics. This achieves the binding of local verification with overall data integrity, ensuring that any modification to sub-data will lead to verification failure. At the same time, it takes into account both fine-grained data verification and global consistency assurance, providing a multi-layered and highly secure integrity verification mechanism for data storage of devices such as electricity meters.
[0155] In an exemplary embodiment, step S105 above, which updates the initial checksum corresponding to each sub-data according to the key value and data length to obtain the updated checksum corresponding to each sub-data, specifically includes the following: updating the initial checksum corresponding to each sub-data according to the current position value, confusion factor, and data length to obtain the processed checksum corresponding to each sub-data; and determining the updated checksum corresponding to each sub-data based on the processed checksum and the initial checksum.
[0156] The post-processed checksum refers to the checksum obtained by updating the initial checksum corresponding to each sub-data based on the current position value, confusion factor, and data length of each sub-data.
[0157] For example, the server adds the current position value and the confusion factor corresponding to each sub-data, and then takes the remainder of the data length. The initial checksum corresponding to the result is used as the processed checksum for each sub-data (for example, if the result is 5, the 5th checksum is taken out). Then, the server performs an XOR operation between the processed checksum and the initial checksum for each sub-data to obtain the updated checksum for each sub-data.
[0158] For example, the updated checksum can be calculated using the following formula:
[0159] Equation (11)
[0160] Here, Len refers to the data length.
[0161] In this embodiment, a composite verification mechanism is adopted, which combines data location characteristics, dynamic confusion factors and data length to perform dual updates on the initial verification code. This not only preserves the integrity of the initial verification but also incorporates dynamic security elements, achieving comprehensive protection of data content, location and length. This significantly improves the security and anti-attack capabilities of the verification code, providing more reliable integrity assurance for data storage of devices such as electricity meters.
[0162] In one exemplary embodiment, such as Figure 2 As shown, another method for storing electricity meter data is provided. Taking the application of this method to a server as an example, the specific steps include:
[0163] Step S201: Obtain the data to be stored associated with the electricity meter and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter.
[0164] Step S202: Perform a first nonlinear transformation on the row number value to obtain the multiplier value corresponding to the data to be stored, and perform a second nonlinear transformation on the row number value to obtain the offset value corresponding to the data to be stored; determine the confusion factor corresponding to the data to be stored based on the row number value, the multiplier value, and the offset value.
[0165] Step S203: Determine the seed value corresponding to the data to be stored based on the row number, multiplier, offset, and obfuscation factor; use the multiplier, offset, obfuscation factor, and seed value as the 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: 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.
[0168] Step S206: Determine the initial checksum corresponding to each sub-data based on each sub-data, position factor, and hash bit.
[0169] Step S207: Based on the current position value, confusion factor and data length of each sub-data, update the initial check code corresponding to each sub-data to obtain the processed check code corresponding to each sub-data.
[0170] Step S208: 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.
[0171] Step S209: Combine the updated check codes corresponding to each sub-data to obtain the target check code corresponding to the data to be stored.
[0172] Step S210: Store the data to be stored and the corresponding target verification code of the data to be stored into the storage table of the electricity meter according to the row number value.
[0173] In the aforementioned data storage method for electricity meters, when storing the meter's data, the row number is first determined based on the data to be stored, and a corresponding key value is generated, dynamically associating the key with the storage location. Then, the target hash value is calculated by combining the key value and the data length, ensuring that the hash value depends on both the data content and the storage environment. Next, the initial checksum of the sub-data is generated using the key value and the hash value, and then the checksum is updated by combining it with the data length, forming a double check. Finally, the updated checksum is combined to obtain the target checksum, which is stored synchronously with the data. This method of deeply coupling storage location, data length, and encryption verification effectively prevents data tampering, forgery of storage locations, and unauthorized access, thus improving data storage security. Moreover, the above process avoids the instability caused by data misalignment when the storage address changes during program upgrades, which could lead to lower data storage security, further enhancing data storage security.
[0174] In one exemplary embodiment, to more clearly illustrate the data storage method for an electricity meter provided in this application, the following specific embodiment will be used to describe the data storage method for the electricity meter. In one embodiment, this application also provides yet another data storage method for an electricity meter. Specifically, it includes the following:
[0175] This embodiment provides a data storage table for an electricity meter, as shown in Table 1:
[0176] Table 1. Data storage table for electricity meters
[0177]
[0178] Specifically, it includes the following:
[0179] 1. Establish a storage table inside the electricity meter. The table has n rows. Each row includes a data identifier, RAM address, EEPROM (Electrically Erasable Programmable Read-Only Memory) address, and length.
[0180] 2. The contents of the RAM address include the data content plus a checksum; the contents of the EEPROM address include the data content plus a checksum.
[0181] 3. The length includes the length of the data content plus the length of the checksum.
[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, it queries the data table through the data identifier. If the data identifier matches, the query is completed, and the row number of the data identifier is also known.
[0183] 5. Based on the RAM address and length of the line number, retrieve the corresponding length of data content plus the checksum from the RAM address.
[0184] 6. Calculate the checksum using a new checksum calculation method based on the row number and data content. If the calculated checksum matches the checksum retrieved from the RAM address, the data is considered correct, and the data is returned to the external device.
[0185] 7. If the calculated check code does not match the check code retrieved from RAM, the data is considered incorrect. Based on the EEPROM address and length of the row number, retrieve the corresponding length of data content plus the check code from the EEPROM.
[0186] 8. Calculate the checksum based on the row number and data content. If the calculated checksum matches the checksum retrieved from the EEPROM, the data is considered correct and returned to the external device; otherwise, an error is acknowledged to the external device. Since the data in RAM is correct in most cases, there is no need to copy the data from the EEPROM, thus ensuring the access efficiency during data copying.
[0187] 9. When an external device sets the data inside the electricity meter through the data identifier, the data table is queried through the data identifier. If the data identifier matches, the query is complete, and the row number of the data is also known.
[0188] 10. Based on the row number, RAM address, and length of the data, calculate the checksum using a new checksum calculation method, and write the data along with the checksum into the RAM address and EEPROM address.
[0189] like Figure 3 As shown, the new checksum calculation method consists of the following steps:
[0190] S1. Generate Keys: Generate multiple keys (including multiplier, offset, confusion factor, and seed value) from the row number using a non-linear function. These keys are used to calculate the checksum. Different row numbers generate different keys, ensuring the sensitivity of the row number.
[0191] S1.1 Calculate the multiplier (8 bits in length): Perform a non-linear transformation using the row number, the prime number 17, and the constant 37, and force conversion to an unsigned 8-bit format (uint8_t):
[0192] Equation (1)
[0193] Prime numbers are chosen for multiplication because they are coprime to most numbers, which reduces the probability of data collisions or uneven data distribution. Other prime numbers can also be used instead. Adding a constant is chosen to enhance the nonlinear transformation and avoid direct mapping between input and output. Other constants can also be used instead (the same applies below).
[0194] S1.2 Calculate the offset (8 bits): Perform a non-linear transformation using the row number, the prime number 23, and the constant 53. To enhance sensitivity to the row number and reduce checksum conflicts, the transformed result is modulo 251 to obtain the offset. This offset is generated in a different data space than the multiplier.
[0195] Equation (2)
[0196] S1.3 Calculate the confusion factor (mix_factor, 8 bits): XOR the multiplier and offset, AND the row number with the hexadecimal number 0xff to obtain the lower 8 bits of the row number, and OR the results to increase the randomness of the confusion factor.
[0197] Equation (3)
[0198] The XOR operation was chosen because it is highly sensitive to changes in the input and can also eliminate linear relationships. Combined with OR and AND operations, it is to enhance the non-linear characteristics of the key (the same applies below).
[0199] S1.4 Calculating the seed value (32 bits): To integrate multi-source information and maximize the use of the information entropy of row numbers 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 left-shifting the row number by 16 bits, bits 15-8 are generated by left-shifting the confusion factor by 8 bits, and bits 7-0 are generated by XORing the offset and the multiplier.
[0200] Equation (4)
[0201] Using a seed value in subsequent checksum calculations can further improve the sensitivity of the row number, ultimately generating a highly sensitive checksum.
[0202] S2. Hash value (32-bit) calculation: Calculate the hash value byte by byte for the data content.
[0203] S2.1 Initialize the hash value as the seed value:
[0204] Equation (5)
[0205] S2.2. Assume the data to be used to calculate the checksum is an array data[Len] of length Len, where data[0] represents the 0th element, data[i] represents the i-th element, and data[Len-1] represents the last element. i is the current loop value, starting from 0 and changing to Len-1, looping for Len times. In the i-th loop, data[i] is first XORed with the product of the hash value and the multiplier, then XORed again with the hash value shifted 13 bits to the right to calculate the hash value. The hash value is then shifted 27 bits to the right or 5 bits to the left to calculate the new hash value. The details are as follows:
[0206] Equation (6)
[0207] Equation (7)
[0208] S3. Calculate the preliminary checksum: Calculate a preliminary checksum of equal length based on the data content. Specific steps include calculating the position factor (pos_factor, 32 bits), calculating the hash bit (hash_bit, 8 bits), and calculating the preliminary checksum [Len] of equal length to the data data [Len]. This process is repeated Len times. The position factor is used to convert row number and position information into dynamic offsets, ensuring the checksum's position sensitivity and row number dependence. Its calculation method is: multiply the current loop value i by the confusion factor, add the offset, and then take the remainder of the result divided by 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, achieving avalanche effect and collision resistance. Its calculation method is: shift the hash value to the right by the current loop value i bits, and then perform a bitwise AND operation with 0xff to obtain the hash bit. The preliminary checksum is calculated as follows: first, XOR the current i-th data data [i] with the hash bit, and then XOR the result with the position factor to obtain the i-th preliminary checksum [i].
[0209] Equation (8)
[0210] Equation (9)
[0211] Equation (10)
[0212] After the loop is completed, a preliminary checksum [Len] of length is generated.
[0213] S4. Calculate the final checksum: After calculating the initial checksum, to further enhance its randomness and diffusion, even minor changes within the data will cause a drastic change in the checksum, reducing the false detection rate. An additional obfuscation step is added to calculate the final checksum [Len]. The calculation method is as follows: First, add the obfuscation factor to the current loop value i, then take the remainder of the data length. The result is the number of checksums to be extracted, and then XORed with the i-th checksum. The result is used as the i-th final checksum [i].
[0214] Equation (11)
[0215] After the loop completes, a final checksum [Len] of length is generated.
[0216] For example: Suppose there are two arrays of length 4, with the same data in hexadecimal format, both data[4]={0x12, 0x34, 0x56, 0x78}, located in the first and second rows of the storage table respectively. According to the above check code calculation method, the check code of the first row array is calculated as {0x2f, 0x2f, 0xef, 0x33}, and the check code of the second row array is {0x3e, 0x46, 0xe1, 0x8c}. It can be seen that the same data has completely different check codes calculated in different row numbers, which is highly sensitive to the row number. This can effectively prevent the data from shifting when the electricity meter is upgraded or there is external interference, and the data with check codes in other row numbers will shift to this row number, resulting in missed detection.
[0217] To illustrate further: Suppose an array data[3]={0x11, 0x22, 0x33} with a length of 3. 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 that the data in this array is unexpected, and the first data changes slightly 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. By calculating the check code, it can be clearly determined whether the data is wrong.
[0218] For example, the array data[1]={0xaa} with a data length of 1 is 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 is 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 length of the data. This can effectively reduce the possibility of false detection when using traditional CRC16 check for long data, where the data content is different but the CRC16 check code is the same.
[0219] In the above embodiment, when storing data from an electricity meter, the row number is first determined based on the data to be stored, and a corresponding key value is generated, dynamically associating the key with the storage location. Then, the target hash value is calculated by combining the key value and the data length, ensuring that the hash value depends on both the data content and the storage environment. Next, the initial checksum of the sub-data is generated using the key value and the hash value, and then the checksum is updated by combining the data length, forming a double check. Finally, the updated checksum is combined to obtain the target checksum, which is stored synchronously with the data. This method of deeply coupling storage location, data length, and encryption verification effectively prevents data tampering, forgery of storage locations, and unauthorized access, thus improving data storage security. Moreover, the above process avoids the instability caused by data misalignment when the storage address changes during program upgrades, which can lead to lower data storage security, further enhancing data storage security.
[0220] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0221] Based on the same inventive concept, this application also provides a data storage device for an electricity meter to implement the aforementioned data storage method. The solution provided by this device is similar to the solution described in the above method. Therefore, the specific limitations of one or more embodiments of the data storage device for an electricity meter provided below can be found in the limitations of the data storage method for the electricity meter described above, and will not be repeated here.
[0222] In one exemplary embodiment, such as Figure 4 As shown, a data storage device for an electricity meter is provided, comprising: a row number value determination module 401, a key value determination module 402, a hash value determination module 403, a verification code determination module 404, a verification code update module 405, a verification 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 electricity meter and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter.
[0224] The key value determination module 402 is used to determine the key value corresponding to the data to be stored based on 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 based on the key value and the data length.
[0226] The verification code determination module 404 is used to determine the initial verification code corresponding to each sub-data in the data to be stored based on the key value and the target hash value.
[0227] The verification code update module 405 is used to update the initial verification code corresponding to each sub-data according to the key value and data length, so as to obtain the updated verification 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 the 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 electricity 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 value corresponding to the data to be stored; determine the obfuscation factor corresponding to the data to be stored based on the row number value, the multiplier value, and the offset value; determine the seed value corresponding to the data to be stored based on the row number value, the multiplier value, the offset value, and the obfuscation factor; and use the multiplier value, the offset value, 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 configured 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 update count corresponding to the updated hash value; 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 update count meets the preset update count; the preset update count is determined by the data length; and use the updated hash value that meets the preset update count 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 the processed hash value corresponding to the data to be stored; and to perform a cyclic shift process on the processed hash value to obtain the updated hash value corresponding to the data to be stored.
[0233] In an exemplary embodiment, the verification code determination module 404 is further configured 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; determine the hash bit corresponding to each sub-data based on the target hash value and the current position value; and determine the initial verification code corresponding to each sub-data based on each sub-data, the position factor and the hash bit.
[0234] In an exemplary embodiment, the checksum update module 405 is further configured to update the initial checksum 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 checksum corresponding to each sub-data; and determine the updated checksum corresponding to each sub-data according to the processed checksum and the initial checksum.
[0235] The various modules in the data storage device of the aforementioned electricity meter can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0236] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as row number values, multiplier values, offsets, and confusion factors. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a data storage method for an electricity meter.
[0237] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0238] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0239] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above-described method embodiments.
[0240] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0241] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, 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 many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0242] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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 embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A data storage method for an electricity meter, characterized in that, The method includes: Obtain the data to be stored associated with the electricity meter, and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter; The row number value is subjected to a first nonlinear transformation to obtain a multiplier value corresponding to the data to be stored, and the row number value is subjected to a second nonlinear transformation to obtain an offset value corresponding to the data to be stored; based on the row number value, the multiplier value, and the offset value, an obfuscation factor corresponding to the data to be stored is determined; based on the row number value, the multiplier value, the offset value, and the obfuscation factor, a seed value corresponding to the data to be stored is determined; the multiplier value, the offset value, the obfuscation factor, and the seed value are all used as the key value corresponding to the data to be stored. Obtain the data length corresponding to the data to be stored, and 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 update count 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 update count meets a preset update count; the preset update count is determined by the data length; the updated hash value that meets the preset update count is used as the target hash value corresponding to the data to be stored. Based on the key value and the target hash value, the initial checksum corresponding to each sub-data in the data to be stored is determined; Based on the key value and the data length, the initial checksum corresponding to each sub-data is updated to obtain the updated checksum corresponding to each sub-data. The updated check codes corresponding to each sub-data are combined to obtain the 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 electricity meter.
2. The method according to claim 1, characterized in that, The step of updating the initial hash value to obtain the updated hash value corresponding to the data to be stored includes: The initial hash value is updated based on each sub-data and the multiplier value to obtain the processed hash value corresponding to the data to be stored. The processed hash value is cyclically shifted to obtain the updated hash value corresponding to the data to be stored.
3. The method according to claim 1, characterized in that, The step of determining the initial checksum corresponding to each sub-data item in the data to be stored based on the key value and the target hash value includes: Obtain the current position value corresponding to each sub-data in the data to be stored; Based on the current position value corresponding to each sub-data, the offset, and the confusion factor, the position factor corresponding to each sub-data is determined, and based on the target hash value and the current position value, the hash bit corresponding to each sub-data is determined. Based on each sub-data, the position factor, and the hash bit, the initial checksum corresponding to each sub-data is determined.
4. The method according to claim 3, characterized in that, The step of updating the initial checksum corresponding to each sub-data item based on the key value and the data length to obtain the updated checksum corresponding to each sub-data item includes: Based on the current position value, the confusion factor, and the data length of each sub-data, the initial check code corresponding to each sub-data is updated to obtain the processed check code corresponding to each sub-data. Based on the processed checksum and the initial checksum corresponding to each sub-data, the updated checksum corresponding to each sub-data is determined.
5. A data storage device for an electricity meter, characterized in that, The device includes: The row number value determination module is used to obtain the data to be stored associated with the electricity meter and determine the row number value corresponding to the data to be stored in the storage table of the electricity meter. The key value determination module is used to perform a first nonlinear transformation on the row number value to obtain a multiplier value corresponding to the data to be stored, and to perform a second nonlinear transformation on the row number value to obtain an offset value 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 value; determine a seed value corresponding to the data to be stored based on the row number value, the multiplier value, the offset value, and the obfuscation factor; and use the multiplier value, the offset value, the obfuscation factor, and the seed value as the key value corresponding to the data to be stored. A hash value determination module is used to obtain the data length corresponding to the data to be stored, 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 update count 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 update count meets a preset update count; the preset update count is determined by the data length; and the updated hash value that meets the preset update count is used as the target hash value corresponding to the data to be stored. The verification code determination module is used to determine the initial verification code corresponding to each sub-data in the data to be stored based on the key value and the target hash value. The verification code update module is used to update the initial verification code corresponding to each sub-data according to the key value and the data length, so as to obtain the updated verification code corresponding to each sub-data. The check code combination module is used to combine the updated check codes corresponding to each sub-data to obtain the 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 into the storage table of the electricity meter according to the row number value.
6. The apparatus according to claim 5, characterized in that, The hash value determination module is further configured to update the initial hash value based on each sub-data and the multiplier value to obtain the processed hash value corresponding to the data to be stored. The processed hash value is cyclically shifted to obtain the updated hash value corresponding to the data to be stored.
7. The apparatus according to claim 5, characterized in that, The verification code determination module is further configured 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 corresponding to each sub-data, the offset, and the confusion factor; determine the hash bit corresponding to each sub-data based on the target hash value and the current position value; and determine the initial verification code corresponding to each sub-data based on each sub-data, the position factor, and the hash bit.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Client verification method and apparatus
CN108259490A
Data processing method, data processing device, electronic equipment and medium
CN112765642A