Method, device and electronic equipment for tamper-proof security protection of electronic files

By performing block reading and character frequency analysis on electronic files, combining position distribution and other file data, calculating and weighting hash values, the problem that fixed weight hash values ​​in the prior art cannot meet high-precision tamper protection, and achieve higher data security and protection effects.

CN119378021BActive Publication Date: 2025-04-15HUNAN CHIYANG INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411960330.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-15
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

The hash value acquisition method with fixed weights in the existing electronic file anti-tampering technology cannot meet the high-precision anti-tampering protection requirements, especially when data blocks containing highly sensitive information in electronic files require a higher degree of protection.

Method used

By reading the electronic files in blocks, the relative frequency parameters of each character in each data block are obtained, and the initial anti-tampering index of each character is calculated based on the position distribution of characters and the data distribution of the same characters in other electronic files. Then, based on the number and position distribution of characters appearing in the data block, the initial tamper-proof indicator is adjusted to obtain the comprehensive tamper-proof degree of each data block. Finally, the hash value is weighted using the comprehensive tamper-proof degree to generate a tamper-proof hash value.

Benefits of technology

It realizes fine adjustments to the degree of tamper-proof tamper-proof of different data blocks in electronic files, provides higher data security and protection effects, and meets the requirements of high-precision tamper-proof protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378021B_ABST
    Figure CN119378021B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data security processing, and in particular to an anti-tampering security protection method, device and electronic device for electronic files, comprising: obtaining relative frequency parameters of each character in each data block in each electronic file; performing data fitting based on the position distribution of each character in each electronic file, and the difference and relative frequency parameters, combining the data distribution of the same character in other electronic files to obtain the initial anti-tampering index of each character in each electronic file; adjusting the initial anti-tampering index based on the number distribution of each character in each data block in each electronic file and the position distribution of the corresponding data block to obtain the comprehensive anti-tampering degree of each data block in each electronic file; and weighting the initial hash value of hash verification of each data block in each electronic file using the comprehensive anti-tampering degree to obtain the anti-tampering hash value. The present invention provides higher data security and protection effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data security processing, and in particular to an anti-tampering security protection method, device and electronic equipment for electronic files. Background Art

[0002] At present, hash verification plays an important role in the field of electronic file tamper-proof technology. Hash verification is an authenticity assurance technology based on hash function calculation. Its principle is to first divide the file into several blocks and calculate the hash value of each block, and then calculate the overall hash value of the electronic file through the chain merging method. When any change occurs to the electronic file, its hash value also changes accordingly, and then the hash value is compared to verify whether the file content has been tampered with.

[0003] However, this method has equal weights for the hash values ​​of each block in the electronic file, which means that the degree of protection of the data in each block is the same. However, considering that the data in some blocks of the electronic file may contain highly sensitive information, the degree to which these blocks need to be protected should be higher. Some blocks of the electronic file contain ordinary information, which means that if this information is tampered with, the overall impact on the electronic file is relatively small, and the security risk is low. Therefore, the hash value acquisition method with fixed weights in the existing electronic file anti-tampering technology cannot meet the requirements of high-precision anti-tampering protection. Summary of the invention

[0004] In order to solve the technical problem that the fixed-weight hash value acquisition method in the existing electronic file anti-tampering technology cannot meet the high-precision anti-tampering protection requirements, the purpose of the present invention is to provide an electronic file anti-tampering security protection method, device and electronic equipment, and the technical solution adopted is as follows:

[0005] In a first aspect, the present invention provides a method for tamper-proofing and protecting an electronic file, comprising:

[0006] Read the electronic files in blocks respectively, and obtain the relative frequency parameter of each character in each data block of each electronic file;

[0007] The difference of data fitting and the relative frequency parameter are performed according to the position distribution of each character in each electronic file, and combined with the data distribution of the same character in other electronic files, to obtain the initial anti-tampering index of each character in each electronic file;

[0008] According to the distribution of the number of each character in each data block in each electronic file and the position distribution of the corresponding data block, the initial tamper-proof index of the same character is adjusted to obtain the comprehensive tamper-proof degree of each data block in each electronic file;

[0009] The comprehensive tamper-proof degree is used to weight the initial hash value of each data block in each electronic file for hash verification to obtain the tamper-proof hash value of each data block in each electronic file.

[0010] Preferably, the difference in data fitting based on the position distribution of each character in each electronic file and the relative frequency parameter, combined with the data distribution of the same character in other electronic files, to obtain the initial anti-tampering index of each character in each electronic file, specifically includes:

[0011] Record any electronic file as a target electronic file, record any character as a target character, and record other electronic files except the target electronic file as reference electronic files;

[0012] Performing data fitting according to the actual position distribution of each occurrence of the target character in the target electronic file to obtain a fitting position order of each occurrence of the target character in the target electronic file;

[0013] In the target electronic file, the absolute value of the difference between the actual position order and the fitting position order of each occurrence of the target character is calculated to obtain the fitting error parameter of each occurrence of the target character; the product of the normalized result of the mean value of the fitting error parameter of all occurrences of the target character in the target electronic file and the relative frequency parameter corresponding to the target character in the target electronic file is used as the structural characteristic factor of the target character in the target electronic file;

[0014] An initial anti-tampering index of the target character in the target electronic file is obtained according to the structural characteristic factor of the target character in the target electronic file and the structural characteristic factor of the target character in the reference electronic file.

[0015] Preferably, performing data fitting according to the actual position distribution of each occurrence of the target character in the target electronic file to obtain the fitting position order of each occurrence of the target character in the target electronic file specifically includes:

[0016] The order in which the target characters appear in the target electronic file is used as the horizontal coordinate, and the actual position order in which the target characters appear in the target electronic file is used as the vertical coordinate to obtain each position parameter coordinate of the target character in the target electronic file; and the position parameter coordinates are used to perform straight line fitting to obtain the position fitting straight line of the target character in the target electronic file;

[0017] The ordinates corresponding to the order of each appearance of the target characters are obtained on the position fitting straight line as the fitting position order of each appearance of the target characters in the target electronic file.

[0018] Preferably, obtaining the initial anti-tampering index of the target character in the target electronic file according to the structural characteristic factor of the target character in the target electronic file and the structural characteristic factor of the target character in the reference electronic file specifically includes:

[0019] The product of the reciprocal of the mean of the structural characteristic factors of the target character in all reference electronic files and the structural characteristic factor of the target character in the target electronic file is used as the initial anti-tampering index of the target character in the target electronic file.

[0020] Preferably, the initial tamper-proof index of the same type of characters is adjusted according to the number distribution of each type of characters in each data block in each electronic file and the position distribution of the corresponding data block to obtain the comprehensive tamper-proof degree of each data block in each electronic file, which specifically includes:

[0021] Recording any electronic file as a selected electronic file, and recording any data block in the selected electronic file as a selected data block;

[0022] Obtaining an anti-tampering characteristic factor of a selected data block in a selected electronic file according to the frequency of occurrence of each character in a selected data block in a selected electronic file and an initial anti-tampering index corresponding to the character;

[0023] According to the position distribution of the selected data block in the selected electronic file, combined with the tamper-proof characteristic factor, the comprehensive tamper-proof degree of the selected data block in the selected electronic file is obtained.

[0024] Preferably, obtaining the anti-tampering characteristic factor of the selected data block in the selected electronic file according to the frequency of occurrence of each character in the selected data block in the selected electronic file and the initial anti-tampering index corresponding to the character specifically includes:

[0025] Record any character as a selected character, and use the proportion of the number of times the selected character appears in the selected data block in the selected electronic file as a feature weight coefficient of the selected character in the selected data block in the selected electronic file;

[0026] The characteristic weight coefficient is used to perform weighted summation on the initial tamper-proof indexes of all characters in the selected data block in the selected electronic file, and the summation result is normalized to obtain the tamper-proof characteristic factor of the selected data block in the selected electronic file.

[0027] Preferably, the step of obtaining the comprehensive tamper resistance degree of the selected data block in the selected electronic file according to the position distribution of the selected data block in the selected electronic file in combination with the tamper resistance characteristic factor specifically includes:

[0028] Obtaining a position serial number of the selected data block in the selected electronic file and recording it as a position parameter of the selected data block in the selected electronic file;

[0029] The normalized value of the absolute value of the difference between the position parameter of the selected data block in the selected electronic file and the median of the position parameters of all data blocks in the selected electronic file is calculated to obtain an adjustment coefficient; the product of the adjustment coefficient and the anti-tampering characteristic factor of the selected data block in the selected electronic file is used as the comprehensive tamper-proof degree of the selected data block in the selected electronic file.

[0030] Preferably, the step of reading the electronic files in blocks respectively and obtaining the relative frequency parameter of each character in each data block in each electronic file specifically includes:

[0031] For any electronic file, the electronic file is read in blocks to obtain each data block of the electronic file;

[0032] For any character, the result of normalizing the maximum and minimum values ​​of all the times that the character appears in the electronic file is used as the relative frequency parameter of the character in each data block in the electronic file.

[0033] In a second aspect, the present invention provides an anti-tampering security protection device for electronic files, the device is used to implement the steps of an anti-tampering security protection method for electronic files, the anti-tampering security protection device for electronic files comprises:

[0034] The data preprocessing module is used to read the electronic files in blocks respectively, and obtain the relative frequency parameters of each character in each data block of each electronic file;

[0035] An initial analysis module, for performing data fitting based on the position distribution of each character in each electronic file and the relative frequency parameter, combined with the data distribution of the same character in other electronic files, to obtain an initial anti-tampering index for each character in each electronic file;

[0036] A comprehensive analysis module is used to adjust the initial tamper-proof index of the same character according to the number distribution of each character in each data block in each electronic file and the position distribution of the corresponding data block, so as to obtain the comprehensive tamper-proof degree of each data block in each electronic file;

[0037] The security protection module is used to weight the initial hash value of each data block in each electronic file by using the comprehensive tamper-proof degree to perform hash verification, so as to obtain the tamper-proof hash value of each data block in each electronic file.

[0038] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of a method for tamper-proofing security protection of electronic files when executing the program.

[0039] The embodiments of the present invention have at least the following beneficial effects:

[0040] The present invention first obtains the relative frequency parameters of characters after electronic files are divided into blocks, preliminarily processes the frequency of characters appearing in electronic files, and provides a data basis for the subsequent importance analysis of characters. Then, the data distribution of each character in each electronic file is analyzed. The first aspect is to analyze the position distribution of the characters for data fitting difference distribution, and combined with the relative frequency parameters, it is intended to analyze whether the position distribution of the characters in the corresponding electronic files conforms to the distribution law of key characters with high specificity and professionalism; the second aspect is to analyze the key distribution of the same characters in other electronic files, and comprehensively characterize the initial anti-tampering situation of the characters in the electronic files. Further, the occurrence of characters in the data blocks in the electronic files and the position distribution of the corresponding data blocks are fully considered, and the initial anti-tampering index is further adjusted from the data distribution of the two aspects, which more comprehensively and accurately characterizes the anti-tampering situation required for the data blocks in the electronic files. Finally, using the required anti-tampering situation, the existing hash value is weighted to obtain the weighted hash value of the data block in the electronic file, which can make the data blocks with higher anti-tampering requirements occupy a greater influence in the digital signature or authentication process, providing higher data security and protection effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 It is a flowchart of the steps of a tamper-proof security protection method for electronic files provided by the present invention;

[0043] Figure 2 It is a flowchart of the steps of the method for obtaining the initial anti-tampering index of the target character in the target electronic file provided by the present invention;

[0044] Figure 3 It is a flowchart of the steps of a method for obtaining a comprehensive tamper resistance degree of a selected data block in a selected electronic file provided by the present invention;

[0045] Figure 4 It is a structural schematic diagram of an anti-tampering security protection device for electronic files provided by the present invention;

[0046] Figure 5 The present invention is a schematic diagram of the structure of an electronic device. DETAILED DESCRIPTION

[0047] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the anti-tampering security protection method, device and electronic device of an electronic file proposed by the present invention, its specific implementation method, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0048] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0049] The following is a detailed description of a method, device and electronic device for tamper-proofing security protection of electronic files provided by the present invention in conjunction with the accompanying drawings.

[0050] See also Figure 1 , which shows a flowchart of a method, device and electronic device for tamper-proof security protection of electronic files provided by an embodiment of the present invention, the method comprising the following steps:

[0051] Step S100 , reading the electronic file in blocks respectively, and obtaining the relative frequency parameter of each character in each data block in each electronic file.

[0052] It should be noted that in the existing hash algorithm, the electronic file to be read is first opened in binary mode, and then each character of the file is traversed to determine the position where each character appears; the information is filled in the read electronic file so that the data bit number is a multiple of 512; further, each time 512 bits of data are read, the electronic file is divided into multiple 512-bit file blocks, and then the hash value of the first file block is obtained, and the hash value of the first file block is used as the hash initial value of the second file block, and the chain processing is repeated to obtain the overall hash value. Based on this, in order to provide a data basis for the subsequent data importance and sensitivity analysis of the data distribution in different file blocks, it is first necessary to read the electronic file in blocks.

[0053] For all the characters in an electronic document, frequently occurring characters are usually the most important information carriers in the text of the electronic document. Tampering with these characters may have a huge impact on the integrity and accuracy of the text. The reasons are as follows. On the one hand, if the text of the electronic document needs to be compressed, frequently occurring characters will use relatively short encodings, and less common characters will use relatively long encodings. The encodings of frequently occurring characters are shorter, and the efficiency of data transmission or storage is higher. Therefore, relatively speaking, frequently occurring characters are more important in the compression process. On the other hand, if the text of the electronic document is encrypted, frequently occurring characters will affect the key generation and encryption structure during the encryption process. To prevent attackers from cracking the ciphertext through frequency analysis, it is crucial to protect frequently occurring characters. If high-frequency characters are tampered with or cracked, the security of the entire encrypted document may be threatened. Based on this, in order to provide a data basis for the degree of tamper prevention required for data characters in different file blocks of an electronic document in subsequent analysis, it is first necessary to obtain the frequency distribution of characters in each electronic document.

[0054] Specifically, in this embodiment, the SHA-256 hash algorithm is used. After each electronic document is read, it is block-processed to obtain multiple 512-bit blocks, which are respectively denoted as data blocks. For any kind of character, the result of normalizing the maximum and minimum values of the number of occurrences of this kind of character in the electronic document is used as the relative frequency parameter of the character in each data block of the electronic document.

[0055] Thus, in the same way, each data block of each electronic document and the relative frequency parameter of each kind of character in each electronic document can be obtained.

[0056] Step S200, based on the differences in data fitting according to the position distribution of each kind of character in each electronic document and the relative frequency parameter, and combining the data distribution of the same characters in other electronic documents, obtain the initial tamper prevention index of each kind of character in each electronic document.

[0057] Considering that the higher the relative frequency of a character's occurrence in an electronic document, the higher the degree of tamper prevention required for the corresponding character. However, on the basis of the same relatively high frequency, the degree of tamper prevention required for the more important key characters and the less important structured characters in the text of the electronic document is different. For example, for an article studying hydrogen, "hydrogen" belongs to the more important key characters, while the structured "de" (of) and "shi" (is) belong to the less important characters. Based on this, for the position distribution of each kind of character in each electronic document, the analysis of the character data distribution can be carried out to quantitatively characterize the tamper prevention situation required for each kind of character in the corresponding electronic document.

[0058] In this embodiment, any one electronic file is taken as an example for illustration. That is, any one electronic file is denoted as the target electronic file, any kind of character is denoted as the target character, and other electronic files except the target electronic file are denoted as reference electronic files. As Figure 2 shown, the method for obtaining the initial anti-tampering index of the target character in the target electronic file can be implemented by steps S201 to S203.

[0059] Step S201: Perform data fitting according to the actual position distribution of each occurrence of the target character in the target electronic file to obtain the fitting position order of each occurrence of the target character in the target electronic file.

[0060] For less important structured characters, due to the structure and rules of the text language, on the basis of a relatively high frequency distribution, the structured characters are also distributed relatively evenly. Presented in terms of data, there will be an approximately linear relationship between the number of occurrences of the structured characters and their positions in the electronic file.

[0061] For example, for an electronic file, the character position serial number corresponding to the position where the character "de" appears for the first time is 10, the character position serial number corresponding to the position where it appears for the second time is 21, the character position serial number corresponding to the position where it appears for the third time is 29, and the character position serial number corresponding to the position where it appears for the fourth time is 42. Among them, the character position serial number represents the character order of the corresponding character in the electronic file. For example, 10 means that the corresponding character is located at the position of the 10th character in the electronic file. Thus, there is an approximately linear relationship between the number of times the character "de" appears and the corresponding character position serial number.

[0062] Based on this, by analyzing the actual position distribution of each occurrence of each character in the electronic file, linear fitting can be performed to obtain the quantization result of the linear relationship of each character in the electronic file.

[0063] Specifically, take the order of occurrence of the target character in the target electronic file as the abscissa, and take the actual position order of each occurrence of the target character in the target electronic file as the ordinate to obtain the coordinate of each position parameter of the target character in the target electronic file; place the coordinate of each position parameter of the target character in a two-dimensional plane rectangular coordinate system, and use the least squares method to perform linear fitting to obtain the position fitting line of the target character in the target electronic file. In this embodiment, the character position serial number is also the actual position order corresponding to the character.

[0064] For example, the character position serial number corresponding to the first occurrence of "的" is 10, and the corresponding position parameter coordinate is (1, 10), where 1 represents the order of occurrence of the character "的" in the electronic file, and 10 represents the actual position order under the corresponding order of occurrence of the character "的" in the electronic file. Furthermore, for the target character, a fitting data is corresponding to each order of occurrence in the target electronic file on the position fitting line, and this fitting data is also the fitting position order. More specifically, the ordinate corresponding to the order of occurrence of the target character each time on the position fitting line is used as the fitting position order of the target character each time it appears in the target electronic file.

[0065] Step S202, according to the difference between the actual position order and the corresponding fitting position order of the target character each time it appears in the target electronic file, combined with the relative frequency parameter, obtain the structural feature factor of the target character in the target electronic file.

[0066] The difference between the actual position order and the corresponding fitting position order of the target character each time it appears in the target electronic file can reflect whether the position distribution of the target character in the target electronic file conforms to a linear relationship. If the position distribution of the target character conforms to a linear change relationship, it indicates that the target character belongs to a structural character, and its importance degree is relatively low, and further indicates that the required anti-tampering degree is lower. If the position distribution of the target character does not conform to a linear change relationship, it indicates that the character may belong to a key character, with a higher corresponding importance degree, and the required anti-tampering degree is also higher. Based on this, the relative frequency parameter can be preliminarily adjusted using the difference analysis result between the actual and fitting of the target character to obtain the parameter adjustment result in the first aspect, and preliminarily quantify the anti-tampering requirements corresponding to the target character.

[0067] Specifically, in the target electronic file, calculate the absolute value of the difference between the actual position order and the fitting position order of the target character each time it appears to obtain the fitting error parameter of the target character each time it appears; the product of the normalization result of the mean value of the fitting error parameters of all occurrences of the target character in the target electronic file and the relative frequency parameter corresponding to the target character in the target electronic file is used as the structural feature factor of the target character in the target electronic file.

[0068] As a specific example, taking the electronic file a as the target electronic file and the i-th type of character as the target character, the structural feature factor of the target character in the target electronic file, that is, the calculation formula of the structural feature factor corresponding to the i-th type of character in the electronic file a, can be expressed as:

[0069]

[0070] Among them, represents the structural characteristic factor of the target character in the target electronic file, that is, the structural characteristic factor corresponding to the i-th character in the electronic file a, i represents the i-th character, that is, the target character, and a represents the electronic file a, that is, the target electronic file; Indicates the total number of times the target character appears in the target electronic file. Indicates the actual position order of the target character appearing for the xth time in the target electronic file. Indicates the fitting position order of the target character appearing for the xth time in the target electronic file, represents the relative frequency parameter of the i-th character in the target electronic file, and Norm( ) represents the linear normalization function.

[0071] It is the fitting error parameter of the target character when it appears for the xth time in the target electronic file, reflecting the difference between the actual position of the target character when it appears for the xth time in the target electronic file and the position fitted by the straight line. The larger the difference is, the less the position distribution of the target character in the target electronic file conforms to the straight line distribution or the linear relationship, which means that the target character is more likely to be a critical character in the target electronic file, and the greater the tamper-proof degree required for the corresponding target character, and thus the larger the value of the structural characteristic factor.

[0072] At the same time, when the frequency of the target character in the target electronic file is higher, it means that the target character is more important in the target electronic file, and thus a higher degree of anti-tampering is required, and the corresponding structural characteristic factor has a larger value. Based on this, the structural characteristic factor preliminarily characterizes the degree of anti-tampering required for a single type of character in an electronic file through the data performance of a single type of character in an electronic file.

[0073] Step S203 , obtaining an initial anti-tampering index of the target character in the target electronic file according to the structural characteristic factor of the target character in the target electronic file and the structural characteristic factor of the target character in the reference electronic file.

[0074] For the characters in electronic files, the higher the professionalism and specificity in each electronic file, the more important information the character contains in the electronic file, and thus the higher the degree of tamper-proofing required for the character in the corresponding electronic file. After preliminarily quantifying the degree of tamper-proofing required for a single type of character in an electronic file, it can be combined with the data distribution of the same character in other electronic files. When the professionalism and specificity of a single type of character in an electronic file are higher, the higher the degree of tamper-proofing required in the electronic file, and the lower the degree of tamper-proofing required in other electronic files.

[0075] Based on this, taking the target electronic file and the target character as an example, the product of the inverse of the mean of the structural characteristic factors of the target character in all reference electronic files and the structural characteristic factor of the target character in the target electronic file is used as the initial anti-tampering indicator of the target character in the target electronic file.

[0076] The method for obtaining the structural characteristic factors of the target characters in all reference electronic files is the same as the method for obtaining the structural characteristic factors of the target characters in the target electronic files. The reciprocal of the mean of the structural characteristic factors of the target characters in all reference electronic files is used as the coefficient. The larger the value of the reciprocal, the smaller the degree of tamper-proofing required for the target characters in other electronic files. At the same time, when the value of the structural characteristic factor of the target character in the target electronic file is larger, the degree of tamper-proofing required for the target character in the target electronic file is larger, which further indicates that the greater the importance of the target character in the target electronic file, the larger the value of the corresponding initial tamper-proof index.

[0077] The initial tamper-proof index of the target character in the target electronic file analyzes the degree of tamper-proofness required for the target character in the target electronic file from two aspects. The first aspect mainly considers the position distribution of each appearance of the target character in the target electronic file. The second aspect mainly considers the particularity of the target character in other electronic files and the required degree of tamper-proofness, and comprehensively analyzes the initial tamper-proofness required for the target character in the target electronic file.

[0078] Step S300, according to the quantity distribution of each character in each data block in each electronic file and the position distribution of the corresponding data block, the initial tamper-proof index of the same character is adjusted to obtain the comprehensive tamper-proof degree of each data block in each electronic file.

[0079] The initial anti-tampering index reflects the degree of anti-tampering required for a single type of character in an electronic file. In the subsequent hash verification process, the hash value is obtained for each data block in the electronic file, and further analysis is required for the distribution of characters in each data block in the electronic file, so as to more accurately quantify the distribution of the degree of anti-tampering required for the information of each data block in each electronic file.

[0080] In this embodiment, any data block in any electronic file is taken as an example for description. That is, any electronic file is recorded as a selected electronic file, and any data block in the selected electronic file is recorded as a selected data block. Figure 3 As shown, the method for obtaining the comprehensive tamper-proof degree of the selected data block in the selected electronic file can be implemented by step S301 and step S302.

[0081] Step S301 , obtaining an anti-tampering characteristic factor of a selected data block in a selected electronic file according to the frequency of occurrence of each character in a selected data block in a selected electronic file and an initial anti-tampering index corresponding to the character.

[0082] First, each data block in an electronic file contains a lot of character information. The higher the tamper-proof degree required for each character contained in the data block, the higher the tamper-proof degree of the corresponding data block as a whole. Taking into account that some characters appear repeatedly in the data block, in order to make the quantitative result of the tamper-proof degree of the data block more accurate, the tamper-proof conditions corresponding to the repeated characters in the data block are weighted.

[0083] Specifically, any character is recorded as a selected character, and the proportion of the number of times the selected character appears in the selected data block in the selected electronic file is used as the feature weight coefficient of the selected character in the selected data block in the selected electronic file; the initial anti-tampering indicators of all characters in the selected data block in the selected electronic file are weighted summed using the feature weight coefficient, and the sum result is normalized to obtain the anti-tampering feature factor of the selected data block in the selected electronic file.

[0084] As a specific example, the electronic file b is taken as the selected electronic file, the nth data block in the selected electronic file is taken as the selected data block, and the tth character is taken as the selected character. Then, the calculation formula of the tamper-proof characteristic factor of the selected data block in the selected electronic file, that is, the tamper-proof characteristic factor of the nth data block in the electronic file b can be expressed as:

[0085]

[0086] in, represents the tamper-proof characteristic factor of the nth data block in the electronic file b, that is, the tamper-proof degree of the selected data block in the selected electronic file; b represents the electronic file b, and n represents the nth data block in the electronic file b; Indicates the number of character types contained in the selected data block in the selected electronic file. Indicates the number of times the t-th character appears in the n-th data block in the electronic file b. represents the number of characters contained in the nth data block in the electronic file b, represents the initial anti-tampering index of the t-th character in the electronic file b, that is, the initial anti-tampering index of the selected character in the selected electronic file; Norm ( ) represents the linear normalization function.

[0087] It reflects the proportion of the number of times the selected character appears in the selected data block in the selected electronic file, that is, the characteristic weight coefficient of the selected character in the selected data block in the selected electronic file, and reflects the repeated occurrence of the selected character in the selected data block. The greater the repeated occurrence, the greater the weighting of the initially determined tamper-proof degree of the character, and finally the tamper-proof characteristic factor adjusted by the first aspect is obtained.

[0088] Step S302, according to the position distribution of the selected data block in the selected electronic file, combined with the anti-tampering characteristic factor, the comprehensive tamper-proof degree of the selected data block in the selected electronic file is obtained.

[0089] Secondly, the anti-tampering characteristic factor reflects the degree of anti-tampering required for the information in a single data block in the electronic file by analyzing the distribution data of the characters appearing in the data block. Furthermore, by analyzing the position distribution of the data block in the electronic file, the anti-tampering situation of each data block can be further weighted and adjusted. Considering that people's memory of information usually has a "primacy effect", that is, the beginning and end of the article have higher importance. Therefore, the more the data block deviates from the center of the electronic file, the closer it is to the first and last blocks, and the higher the degree of anti-tampering required.

[0090] Specifically, the position number of the selected data block in the selected electronic file is obtained and recorded as the position parameter of the selected data block in the selected electronic file; for example, in any electronic file, the position number of the 6th data block is 6, and the corresponding position parameter value is also 6.

[0091] The normalized value of the absolute value of the difference between the position parameter of the selected data block in the selected electronic file and the median of the position parameters of all data blocks in the selected electronic file is calculated to obtain an adjustment coefficient; the product of the adjustment coefficient and the anti-tampering characteristic factor of the selected data block in the selected electronic file is used as the comprehensive tamper-proof degree of the selected data block in the selected electronic file.

[0092] As a specific example, the adjustment coefficient corresponding to the selected data block in the selected electronic file can be expressed as: ,in represents the adjustment coefficient corresponding to the selected data block in the electronic file, b represents the electronic file b, and n represents the nth data block in the electronic file b. represents the position parameter of the nth data block in the electronic file b, that is, the position parameter of the selected data block in the selected electronic file; Represents the median of the position parameters of all data blocks in the electronic file b, and selects the median of the position parameters of all data blocks in the electronic file.

[0093] It reflects the position sequence of the data block located in the center of the electronic file b. It reflects the distance difference between the selected data block in the selected electronic file and the center position of the selected electronic file. The larger the difference, the closer the selected data block is to the beginning and end of the selected electronic file. The higher the required tamper-proof degree is, the larger the value of the adjustment coefficient is. This embodiment expresses the ratio of the difference to the median. The normalized value of is used to obtain the adjustment coefficient.

[0094] When the adjustment coefficient value is larger, the degree of tamper-proofing required for the selected electronic block in the selected electronic file is greater. The comprehensive tamper-proofing degree is obtained by multiplying the adjustment coefficient with the corresponding tamper-proofing characteristic factor, which can more comprehensively characterize the degree of tamper-proofing ultimately required for the selected data block in the selected electronic file.

[0095] Step S400: weighting the initial hash value of each data block in each electronic file by hash checking using the comprehensive tamper-proof degree to obtain the tamper-proof hash value of each data block in each electronic file.

[0096] The comprehensive tamper-proof degree of each data block in each electronic file reflects the degree of tamper-proofness required for the information in the corresponding data block, and further characterizes the importance and characteristic degree of the data block in the electronic file. The initial hash value of each data block in each electronic file is weighted by a higher comprehensive tamper-proof degree, and then chained and merged to obtain the overall hash value of the electronic file. This can make data blocks with higher tamper-proof requirements have a greater influence in the digital signature or authentication process, providing higher security and data protection effects.

[0097] In this embodiment, the hash value of each data block in each electronic file is first obtained by using the existing hash algorithm as the initial hash value. Then, the product of the comprehensive tamper-proof degree of each data block in each electronic file and the initial hash value is rounded down as the tamper-proof hash value of each data block in each electronic file. Then, the tamper-proof hash value of each data block in each electronic file is chained and processed to obtain the overall hash value of each electronic file. The overall hash value is the unique digital fingerprint of the corresponding content of each electronic file.

[0098] It is understandable that using hash values ​​for chain processing to obtain the overall hash value of a file is a well-known technique in hash verification technology, which will not be described in detail here. Furthermore, after obtaining the overall hash value of each electronic file, judging the tampering of the electronic file based on hash verification technology is a well-known technique, which will not be described in detail here.

[0099] The present invention also provides a tamper-proof security protection device for electronic files, see Figure 4 , which shows a schematic diagram of the structure of an electronic file tamper-proof security protection device provided by an embodiment of the present invention, the device is used to implement the steps of the electronic file tamper-proof security protection method introduced above, the electronic file tamper-proof security protection device includes:

[0100] A data preprocessing module is used to read the electronic files in blocks respectively, and obtain the relative frequency parameters of each character in each data block of each electronic file;

[0101] An initial analysis module, for performing data fitting based on the position distribution of each character in each electronic file and the relative frequency parameter, combined with the data distribution of the same character in other electronic files, to obtain an initial anti-tampering index for each character in each electronic file;

[0102] A comprehensive analysis module is used to adjust the initial tamper-proof index of the same character according to the number distribution of each character in each data block in each electronic file and the position distribution of the corresponding data block, so as to obtain the comprehensive tamper-proof degree of each data block in each electronic file;

[0103] The security protection module is used to weight the initial hash value of each data block in each electronic file by using the comprehensive tamper-proof degree to perform hash verification, so as to obtain the tamper-proof hash value of each data block in each electronic file.

[0104] The present invention also provides an electronic device, see Figure 5 , which shows a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, the electronic device includes a memory 501, a processor 502, and a computer program 503 stored in the memory 501 and running on the processor 502, wherein when the processor 502 executes the computer program 503, the computer device can execute the steps of the anti-tampering security protection method for electronic files introduced above.

[0105] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for protecting electronic files from tampering, characterized in that: The method comprises the following steps: Read the electronic files in blocks respectively, and obtain the relative frequency parameter of each character in each data block of each electronic file; The difference of data fitting and the relative frequency parameter are performed according to the position distribution of each character in each electronic file, and combined with the data distribution of the same character in other electronic files, to obtain the initial anti-tampering index of each character in each electronic file; According to the distribution of the number of each character in each data block in each electronic file and the position distribution of the corresponding data block, the initial tamper-proof index of the same character is adjusted to obtain the comprehensive tamper-proof degree of each data block in each electronic file; Using the comprehensive tamper-proof degree to weight the initial hash value of each data block in each electronic file for hash verification, to obtain the tamper-proof hash value of each data block in each electronic file; The difference in data fitting based on the position distribution of each character in each electronic file and the relative frequency parameter, combined with the data distribution of the same character in other electronic files, obtains the initial anti-tampering index of each character in each electronic file, specifically including: Record any electronic file as a target electronic file, record any character as a target character, and record other electronic files except the target electronic file as reference electronic files; Performing data fitting according to the actual position distribution of each occurrence of the target character in the target electronic file to obtain a fitting position order of each occurrence of the target character in the target electronic file; In the target electronic file, the absolute value of the difference between the actual position order and the fitting position order of each occurrence of the target character is calculated to obtain the fitting error parameter of each occurrence of the target character; the product of the normalized result of the mean value of the fitting error parameter of all occurrences of the target character in the target electronic file and the relative frequency parameter corresponding to the target character in the target electronic file is used as the structural characteristic factor of the target character in the target electronic file; Obtaining an initial anti-tampering index of the target character in the target electronic file according to the structural characteristic factor of the target character in the target electronic file and the structural characteristic factor of the target character in the reference electronic file; The step of performing data fitting according to the actual position distribution of each occurrence of the target character in the target electronic file to obtain the fitting position order of each occurrence of the target character in the target electronic file specifically includes: The order in which the target characters appear in the target electronic file is used as the horizontal coordinate, and the actual position order in which the target characters appear in the target electronic file is used as the vertical coordinate to obtain each position parameter coordinate of the target character in the target electronic file; and the position parameter coordinates are used to perform straight line fitting to obtain the position fitting straight line of the target character in the target electronic file; Obtaining the ordinate corresponding to the order of each appearance of the target character on the position fitting straight line as the fitting position order of each appearance of the target character in the target electronic file; The step of obtaining the initial anti-tampering index of the target character in the target electronic file according to the structural characteristic factor of the target character in the target electronic file and the structural characteristic factor of the target character in the reference electronic file specifically includes: The product of the reciprocal of the mean of the structural characteristic factors of the target character in all reference electronic files and the structural characteristic factor of the target character in the target electronic file is used as the initial anti-tampering index of the target character in the target electronic file.

2. The method for protecting electronic files from tampering according to claim 1, characterized in that: According to the distribution of the number of each character in each data block in each electronic file and the position distribution of the corresponding data block, the initial tamper-proof index of the same character is adjusted to obtain the comprehensive tamper-proof degree of each data block in each electronic file, which specifically includes: Recording any electronic file as a selected electronic file, and recording any data block in the selected electronic file as a selected data block; Obtaining an anti-tampering characteristic factor of a selected data block in a selected electronic file according to the frequency of occurrence of each character in a selected data block in a selected electronic file and an initial anti-tampering index corresponding to the character; According to the position distribution of the selected data block in the selected electronic file, combined with the tamper-proof characteristic factor, the comprehensive tamper-proof degree of the selected data block in the selected electronic file is obtained.

3. The method for protecting electronic files from tampering according to claim 2, characterized in that: The method of obtaining the tamper-proof characteristic factor of the selected data block in the selected electronic file according to the frequency of occurrence of each character in the selected data block in the selected electronic file and the initial tamper-proof index corresponding to the character specifically includes: Record any character as a selected character, and use the proportion of the number of times the selected character appears in the selected data block in the selected electronic file as a feature weight coefficient of the selected character in the selected data block in the selected electronic file; The characteristic weight coefficient is used to perform weighted summation on the initial tamper-proof indexes of all characters in the selected data block in the selected electronic file, and the summation result is normalized to obtain the tamper-proof characteristic factor of the selected data block in the selected electronic file.

4. The method for protecting electronic files from tampering according to claim 3, characterized in that: The step of obtaining the comprehensive tamper resistance degree of the selected data block in the selected electronic file according to the position distribution of the selected data block in the selected electronic file and combining the tamper resistance characteristic factor specifically includes: Obtaining a position serial number of the selected data block in the selected electronic file and recording it as a position parameter of the selected data block in the selected electronic file; The normalized value of the absolute value of the difference between the position parameter of the selected data block in the selected electronic file and the median of the position parameters of all data blocks in the selected electronic file is calculated to obtain an adjustment coefficient; the product of the adjustment coefficient and the anti-tampering characteristic factor of the selected data block in the selected electronic file is used as the comprehensive tamper-proof degree of the selected data block in the selected electronic file.

5. The method for protecting electronic files from tampering according to claim 1, characterized in that: The step of reading the electronic files in blocks respectively and obtaining the relative frequency parameter of each character in each data block of each electronic file specifically includes: For any electronic file, the electronic file is read in blocks to obtain each data block of the electronic file; For any character, the result of normalizing the maximum and minimum values ​​of all the times that the character appears in the electronic file is used as the relative frequency parameter of the character in each data block in the electronic file.

6. An anti-tampering security protection device for electronic files, characterized in that: The device is used to implement the steps of the anti-tampering security protection method for electronic files as described in any one of claims 1 to 5, and the anti-tampering security protection device for electronic files comprises: The data preprocessing module is used to read the electronic files in blocks respectively, and obtain the relative frequency parameters of each character in each data block of each electronic file; An initial analysis module, for performing data fitting based on the position distribution of each character in each electronic file and the relative frequency parameter, combined with the data distribution of the same character in other electronic files, to obtain an initial anti-tampering index for each character in each electronic file; A comprehensive analysis module is used to adjust the initial tamper-proof index of the same character according to the number distribution of each character in each data block in each electronic file and the position distribution of the corresponding data block, so as to obtain the comprehensive tamper-proof degree of each data block in each electronic file; The security protection module is used to weight the initial hash value of each data block in each electronic file by using the comprehensive tamper-proof degree to perform hash verification, so as to obtain the tamper-proof hash value of each data block in each electronic file.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the steps of the anti-tampering security protection method for electronic files as described in any one of claims 1-5 are implemented.

Citation Information

Patent Citations

  • Method and device for detecting ransomware encrypted file

    CN118484803A