Watermark marking and extracting method and device for data file

Through the summary calculation of power scheduling data and the watermark marking and extraction method generated by random algorithm conversion, the problem of tampering risks during data file transmission is solved, and data file transmission with high concealment and security is achieved.

CN119598426APending Publication Date: 2025-03-11STATE GRID JIANGSU ELECTRIC POWER CO LTD TAIZHOU POWER SUPPLY BRANCH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411624084.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

Power scheduling data is easily maliciously tampered with during transmission, and the existing watermark algorithms are insufficient in the multi-dimensional timing measurement data and device status data.

Method used

By performing summary calculations on the original data file, the digest information is generated and a series of conversions are performed as watermarks. The more concealed watermark marking and extraction methods include using a random algorithm to convert the digest information into a random integer, generating a binary string watermark, and inserting a watermark in the data file.

Benefits of technology

It improves the security and reliability of data file transmission, is more concealed and not easy to crack, and can accurately determine whether the data file has been tampered with, ensuring the integrity and accuracy of the data file.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119598426A_ABST
    Figure CN119598426A_ABST
Patent Text Reader

Abstract

The invention discloses a watermark marking and extracting method and device for a data file, and the method comprises the steps: carrying out abstract calculation based on an original data file, and obtaining original abstract information; converting the original summary information into a character string with the same format as the original data file to obtain an original summary information character string; taking an agreed watermark key as a seed, converting each character in the original summary information character string into a random integer by adopting a random algorithm, and performing binary conversion to generate a watermark; marking the generated watermark into an original data file to obtain a marked file; when the watermark is extracted, the watermark is extracted from the marked file according to the position of the watermark mark, and a restored data file is obtained; restoring the extracted watermark to obtain first restored summary information; and performing abstract calculation based on the restored data file to obtain second restored abstract information, and judging whether the data file is tampered or not. The method can ensure the security of data file transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of security technology, and in particular to a watermark marking and extraction method and device for data files. Background Art

[0002] The power industry is the most basic foundation of the country and the people. Power dispatching data is extremely important data for the operation of the power grid. If effective protection measures are not taken during the transmission of this data, it will be maliciously tampered with and its authenticity cannot be proved. The data will not be transmitted completely and truthfully, which may pose a huge risk to the safe operation of the power grid.

[0003] Therefore, the protection of the content of power dispatch data during transmission is an extremely important issue. The power dispatch data text is usually a .e or .DT suffix text, and most of the data is multi-dimensional time series measurement data and equipment status data, without many complex texts. In such a scenario, ordinary document format-based watermark algorithms and document structure-based watermark algorithms are not applicable. For example, patent text CN103310130B discloses a method for embedding and extracting digital watermarks for text documents. The watermark embedding is to make the original information into a binary image, and use programming software such as matlab to read out the binary matrix corresponding to it as watermark information, and then write the two binary code characters "0" and "1" into the font library of the TrueType character creation program to generate a key, and then use the "internal code" input method of windows to retrieve the binary code characters to insert the above binary matrix into the text document, and finally use the "hidden text" function of the word processing software to hide the embedded binary matrix, that is, to complete the watermark embedding. Patent document CN114637972A provides a watermark embedding method based on docx format documents, including the following steps: S110, converting the information to be embedded into a hexadecimal string; S120, processing each character in the string into an identifier, the first six bits of the identifier are 0, the seventh bit represents the position, and the eighth bit is the character; S130, parsing the docx format document to be embedded with a watermark, obtaining a settings.xml file; S140, writing the identifier into the settings.xml file to complete the watermark embedding; the steps S110 to S140 are executed in sequence or in the order of step S130, step S110, step S120, and step S140; and the corresponding watermark extraction method is also disclosed. For docx format documents, it belongs to a subclass of the OOXML format, and the watermark embedding is completed by writing the identifier into the settings.xml file. In the above method, 0 and 1 are used as watermarks. For DT files that are both timing measurement data and equipment status data, the integrity and accuracy of the original data may be interfered with, and the embedded characters may affect the normal use of the file. Using identifiers as watermarks is easy to identify and has low concealment. Summary of the invention

[0004] The present invention provides a watermark marking and extraction method and device for data files, which is suitable for data files and has higher concealment.

[0005] A watermark marking and extraction method for data files, comprising:

[0006] Perform summary calculation based on the original data file to obtain original summary information;

[0007] Converting the original summary information into a character string having the same format as the original data file to obtain an original summary information character string;

[0008] Using the agreed watermark key as a seed, converting each character in the original summary information string into a random integer using a random algorithm, and performing binary conversion on the random integer to generate a watermark;

[0009] Mark the generated watermark into the original data file to obtain a marked file;

[0010] When extracting the watermark, the watermark is extracted from the mark file according to the position of the watermark mark to obtain the restored data file;

[0011] Performing restoration processing on the extracted watermark to obtain first restoration summary information;

[0012] Performing summary calculation based on the restored data file to obtain second restored summary information;

[0013] Whether the data file has been tampered with is determined according to the first restoration summary information and the second restoration summary information.

[0014] Furthermore, the format of the data file is a database file or an Easy Language file.

[0015] Furthermore, a summary calculation is performed based on the original data file to obtain original summary information, including:

[0016] Initialization vector;

[0017] Split the initialized vector into multiple sub-vectors and assign an initial value to each sub-vector;

[0018] Fill the original data file so that the length of the filled data file is an integer multiple of the length of the initialized vector;

[0019] Divide the filled data file according to the length of the initialized vector to obtain primary data blocks of corresponding lengths;

[0020] Dividing the primary data block into blocks to obtain secondary data blocks;

[0021] Perform a preset number of iterative calculations on each secondary data block according to the sub-vectors, merge the sub-vectors output after the preset number of iterative calculations, and use the merged output vector as the original summary information.

[0022] Furthermore, the original data file is padded so that the length of the padded data file is an integer multiple of the length of the initialized vector, including:

[0023] Obtain the length of the original data file, and convert the length into a 64-bit binary representation;

[0024] 1 and the 64-bit binary representation are added to the end of the original data file, and 0 is filled between 1 and the 64-bit binary representation, so that the length of the filled data file is an integer multiple of the length of the initialized vector.

[0025] Furthermore, the agreed watermark key is used as a seed, and a random algorithm is used to convert each character in the original summary information string into a random integer, including:

[0026] Perform a bitwise exclusive OR operation on each character in the original summary information string and the seed to generate the random integer.

[0027] Furthermore, the generated watermark is marked into the original data file to obtain a marked file, including:

[0028] Insert the binary string corresponding to each random integer in the generated watermark into each agreed position of the original data file;

[0029] When the generated watermark is inserted, insert the end mark at the end position of the watermark;

[0030] Traverse and insert each of the binary strings into the original data file, and when the binary character is 1, replace it with a placeholder.

[0031] Further, according to the position of the watermark mark, the watermark is extracted from the mark file to obtain the restored data file, including:

[0032] Traversing the tag file, extracting binary strings from each agreed position, and when a placeholder is detected, recording the character as 1;

[0033] When the terminator is detected, the extracted binary strings are combined to obtain the extracted watermark and the restored data file.

[0034] Furthermore, the extracted watermark is restored to obtain first restored summary information, including:

[0035] Convert the binary string in the extracted watermark into an integer;

[0036] Restoring the converted integer according to the watermark key to obtain a restored summary information character string;

[0037] The format of the restoration summary information character string is converted to obtain first restoration summary information.

[0038] Further, judging whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information includes:

[0039] The first restoration summary information is compared with the second restoration summary information. If the first restoration summary information and the second restoration summary information are different, it is determined that the data file has been tampered with.

[0040] A watermark marking and extraction device for data files, comprising:

[0041] A first summary calculation module, used to perform summary calculation based on the original data file to obtain original summary information;

[0042] A character conversion module, used for converting the original summary information into a character string having the same format as the original data file, to obtain an original summary information character string;

[0043] A watermark generation module, used to use the agreed watermark key as a seed, adopt a random algorithm to convert each character in the original summary information string into a random integer, and perform binary conversion on the random integer to generate a watermark;

[0044] A marking module is used to mark the generated watermark into the original data file to obtain a marked file;

[0045] A watermark extraction module is used to extract the watermark from the mark file according to the position of the watermark mark when extracting the watermark, so as to obtain a restored data file;

[0046] A restoration module, used for performing restoration processing on the extracted watermark to obtain first restoration summary information;

[0047] A second summary calculation module performs summary calculation based on the restored data file to obtain second restored summary information;

[0048] The tampering judgment module is used to judge whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information.

[0049] Furthermore, the format of the data file is a database file or an Easy Language file.

[0050] Furthermore, the first summary calculation module performs summary calculation based on the original data file to obtain original summary information, including:

[0051] Initialization vector;

[0052] Split the initialized vector into multiple sub-vectors and assign an initial value to each sub-vector;

[0053] Fill the original data file so that the length of the filled data file is an integer multiple of the length of the initialized vector;

[0054] Divide the filled data file according to the length of the initialized vector to obtain primary data blocks of corresponding lengths;

[0055] Dividing the primary data block into blocks to obtain secondary data blocks;

[0056] Perform a preset number of iterative calculations on each secondary data block according to the sub-vectors, merge the sub-vectors output after the preset number of iterative calculations, and use the merged output vector as the original summary information.

[0057] Furthermore, the first summary calculation module fills the original data file so that the length of the filled data file is an integer multiple of the length of the initialized vector, including:

[0058] Obtain the length of the original data file, and convert the length into a 64-bit binary representation;

[0059] 1 and the 64-bit binary representation are added to the end of the original data file, and 0 is filled between 1 and the 64-bit binary representation, so that the length of the filled data file is an integer multiple of the length of the initialized vector.

[0060] Furthermore, the watermark generation module uses the agreed watermark key as a seed and adopts a random algorithm to convert each character in the original summary information string into a random integer, including:

[0061] Perform a bitwise exclusive OR operation on each character in the original summary information string and the seed to generate the random integer.

[0062] Furthermore, the marking module marks the generated watermark into the original data file to obtain a marking file, including:

[0063] Insert the binary string corresponding to each random integer in the generated watermark into each agreed position of the original data file;

[0064] When the generated watermark is inserted, insert the end mark at the end position of the watermark;

[0065] Traverse and insert each of the binary strings into the original data file, and when the binary character is 1, replace it with a placeholder.

[0066] Furthermore, the watermark extraction module extracts the watermark from the mark file according to the position of the watermark mark to obtain the restored data file, including:

[0067] Traversing the tag file, extracting binary strings from each agreed position, and when a placeholder is detected, recording the character as 1;

[0068] When the terminator is detected, the extracted binary strings are combined to obtain the extracted watermark and the restored data file.

[0069] Furthermore, the restoration module performs restoration processing on the extracted watermark to obtain first restoration summary information, including:

[0070] Convert the binary string in the extracted watermark into an integer;

[0071] Restoring the converted integer according to the watermark key to obtain a restored summary information character string;

[0072] The format of the restoration summary information character string is converted to obtain first restoration summary information.

[0073] Furthermore, the tampering judgment module judges whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information, including:

[0074] The first restoration summary information is compared with the second restoration summary information. If the first restoration summary information and the second restoration summary information are different, it is determined that the data file has been tampered with.

[0075] The watermark marking and extraction method and device for data files provided by the present invention have at least the following beneficial effects:

[0076] (1) The summary information obtained by performing a series of transformations based on the summary calculation of the original data file is used as a watermark. On the one hand, it is more concealed and difficult to detect, and on the other hand, it is difficult to crack, thereby improving the security and reliability of data file transmission;

[0077] (2) Generate a binary string watermark and replace 1 with a non-display placeholder when inserting the watermark, further improving the concealment without interfering with the data file, thus ensuring the integrity and accuracy of the original data file;

[0078] (3) The calculated summary information is used as the basis for watermarking and tampering judgment, which can more accurately determine whether the data file has been tampered with, further ensuring the security of data file transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0079] Figure 1 The present invention provides a flowchart of an embodiment of a method for watermarking and extracting data files provided by the present invention.

[0080] Figure 2The present invention provides a flowchart of an embodiment of summary calculation in the watermark marking and extraction method for data files.

[0081] Figure 3 The present invention provides a flowchart of an embodiment of marking watermarks in the watermark marking and extraction method for data files.

[0082] Figure 4 The present invention provides a flowchart of an embodiment of extracting a watermark in the watermark marking and extraction method for data files provided by the present invention.

[0083] Figure 5 The present invention provides a flowchart of an embodiment of restoring a watermark in a watermark marking and extraction method for a data file.

[0084] Figure 6 A flow chart of an embodiment of a watermark marking and extraction device for data files provided by the present invention. DETAILED DESCRIPTION

[0085] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0086] refer to Figure 1 In some embodiments, a watermark marking and extraction method for a data file is provided, comprising:

[0087] S1. Perform summary calculation based on the original data file to obtain original summary information;

[0088] S2, converting the original summary information into a character string having the same format as the original data file to obtain an original summary information character string;

[0089] S3, using the agreed watermark key as a seed, using a random algorithm to convert each character in the original summary information string into a random integer, and performing binary conversion on the random integer to generate a watermark;

[0090] S4, marking the generated watermark into the original data file to obtain a marked file;

[0091] S5, when extracting the watermark, extract the watermark from the mark file according to the position of the watermark mark to obtain a restored data file;

[0092] S6, performing restoration processing on the extracted watermark to obtain first restoration summary information;

[0093] S7, performing summary calculation based on the restored data file to obtain second restored summary information;

[0094] S8. Determine whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information.

[0095] Specifically, in step S1, the format of the data file is a database file or an easy language file, that is, the suffix of the data file is .DT or .e. Files in this format are suitable for transmission of power dispatching data.

[0096] Further, refer to Figure 2 In step S1, a summary calculation is performed based on the original data file to obtain original summary information, including:

[0097] S11, initialization vector;

[0098] S12, splitting the initialized vector into multiple sub-vectors, and assigning an initial value to each sub-vector;

[0099] S13, filling the original data file so that the length of the filled data file is an integer multiple of the length of the initialized vector;

[0100] S14, dividing the filled data file according to the initialized vector length to obtain primary data blocks of corresponding length;

[0101] S15, dividing the primary data block into blocks to obtain secondary data blocks;

[0102] S16. Perform a preset number of iterative calculations on each secondary data block according to the sub-vectors, merge the sub-vectors output after the preset number of iterative calculations, and use the merged output vector as the original summary information.

[0103] Specifically, in step S11, a vector is initialized, and the length of the initialized vector is fixed, for example, the length may be 512 bits.

[0104] In step S12, the initialized vector is split into multiple sub-vectors. For example, for a 512-bit initialized vector, it can be split into eight sub-vectors, such as sub-vector A, sub-vector B, sub-vector C, sub-vector D, sub-vector E, sub-vector F, sub-vector G, and sub-vector H, and initial values ​​are assigned to them: A=7380166f, B=4914b2b9, C=172442d7, D=da8a0600, E=a96f30bc, F=163138aa, G=e38dee4d, and H=b0fb0e4e.

[0105] Furthermore, in step S13, the original data file is padded so that the length of the padded data file is an integer multiple of the length of the initialized vector, including:

[0106] Obtain the length of the original data file, and convert the length into a 64-bit binary representation;

[0107] 1 and the 64-bit binary representation are added to the end of the original data file, and 0 is filled between 1 and the 64-bit binary representation, so that the length of the filled data file is an integer multiple of the length of the initialized vector.

[0108] Specifically, the length of the original data file is obtained, converted into a 64-bit binary representation in bits, and 1 and the 64-bit binary representation are added to the end of the original data file, and 0 is filled in between, the number of 0s is determined by the length of the entire data file, and the length of the padded data file is an integer multiple of the length of the initialized vector. For example, if the length of the initialized vector is 512 bits, the length of the padded data file is an integer multiple of 512.

[0109] Furthermore, in step S14, the padded data file is divided according to the initialized vector length. For example, if the initialized vector length is 512 bits, the padded data file is divided into first data blocks of 512 bits in length.

[0110] Furthermore, in step S15, the 512-bit primary data block is further divided to obtain a secondary data block, for example, the length of the secondary data block is 32 bits.

[0111] Furthermore, in step S16, a preset number of iterative calculations are performed on each secondary data block according to the subvector, specifically:

[0112] SS1=ROTL((SS1+SS0+FF(A,B,C,j)+W[j]+T[j])mod 2^32,7); (1)

[0113]

[0114] TT1=ROTL((TT1+TT0+GG(E,F,G,j)+W[j+64]+T[j])mod2^32,7); (3)

[0115]

[0116] A=FF(A,B,C,j)+D+SS2+W[j]+T[j]; (5)

[0117] B=ROTL(A,9); (6)

[0118]

[0119] D=ROTL(C,14); (8)

[0120] E=GG(E,F,G,j)+H+TT2+W[j+64]+T[j]; (9)

[0121] F=ROTL(E,9); (10)

[0122]

[0123] H=ROTL(G,14); (12)

[0124] Among them, A, B, C, D, E, F, G, H represent sub-vectors, SS0 is the linear combination of the sub-vectors A, B, C, D of the previous round, SS1 is the linear combination of the sub-vectors E, F, G, H of the previous round, TT0 and TT1 are intermediate variables used in iteration to update the word vectors E, F, G, H, FF represents the FF function, GG represents the GG function: W[j] represents the j-th secondary data block, T[j] represents a preset constant array containing 64 32-bit integers, and the integer value can be generated by an agreed mathematical formula, ROTL represents a shift instruction, ⊕ represents an exclusive-OR operation, and mod represents a modulo operation.

[0125] When 0≤j<16; (13)

[0126] When 16≤j<64; (14)

[0127] GG(X,Y,Z,j)=(X∧Y)∨(X∧Z)∨(Y∧Z), when 0≤j<16; (15)

[0128] When 16≤j<64; (16)

[0129] In each iterative calculation, the sub-vectors A, B, C, D, E, F, G, and H are updated according to the above formulas (1)-(15). In some embodiments, the number of iterations may be 64 times, that is, when the iteration reaches 64 times, the updated sub-vectors A, B, C, D, E, F, G, and H are output and merged as the original summary information.

[0130] Further, in step S2, the format of the data file is a database file or an Easy Language file, that is, a file with a suffix of .DT or .e. According to the encoding format requirements defined by the DT file or the E language, the original summary information is converted into a string with the same format as the original data file to obtain the original summary information string.

[0131] Furthermore, in step S3, the agreed watermark key is used as a seed, and a random algorithm is used to convert each character in the original summary information string into a random integer, including:

[0132] Perform a bitwise exclusive OR operation on each character in the original summary information string and the seed to generate the random integer.

[0133] Specifically, the generated random integer is between 0 and 255, and each random integer is converted into a binary number to generate an eight-bit binary string, thereby generating a watermark.

[0134] Further, refer to Figure 3 In step S4, the generated watermark is marked into the original data file to obtain a marked file, including:

[0135] S41, inserting the binary string corresponding to each random integer in the generated watermark into each agreed position of the original data file;

[0136] S42, when the generated watermark is inserted, inserting an end symbol at the end position of the watermark;

[0137] S43, traverse and insert each binary string into the original data file, and when the binary character is 1, replace it with a placeholder.

[0138] Specifically, in the obtained markup file, the placeholder is not displayed, so that the watermark is not easily detected, has higher concealment, and does not interfere with the original data file.

[0139] Further, refer to Figure 4 In step S5, according to the position of the watermark mark, the watermark is extracted from the mark file to obtain the restored data file, including:

[0140] S51, traversing the tag file, extracting binary strings from each agreed position, and when a placeholder is detected, recording the character as 1;

[0141] S52: When the end character is detected, the extracted binary character strings are combined to obtain the extracted watermark and the restored data file.

[0142] Further, refer to Figure 5 In step S6, the extracted watermark is restored to obtain first restored summary information, including:

[0143] S61, converting the binary string in the extracted watermark into an integer;

[0144] S62, restoring the converted integer according to the watermark key to obtain a restored summary information character string;

[0145] S63: Perform format conversion on the restoration summary information character string to obtain first restoration summary information.

[0146] Furthermore, in step S61, the length of the extracted watermark is calculated and divided into 8-bit parts, and each 8-bit binary string is converted into an integer.

[0147] In step S62, the previously agreed key is used as a seed to initialize the random number generator, which ensures that the random number sequence generated each time is the same.

[0148] In step S63, the restored summary information character string is in the same format as the original data file, and is converted to obtain first restored summary information.

[0149] Furthermore, in step S7, a summary calculation is performed based on the restored data file to obtain second restored summary information, including:

[0150] S71, initialization vector;

[0151] S72, splitting the initialized vector into multiple sub-vectors, and assigning an initial value to each sub-vector;

[0152] S73, padding the restored data file so that the length of the restored data file after padding is an integer multiple of the length of the initialized vector;

[0153] S14, dividing the restored filled data file according to the initialized vector length to obtain primary data blocks of corresponding length;

[0154] S15, dividing the primary data block into blocks to obtain secondary data blocks;

[0155] S16. Perform a preset number of iterative calculations on each secondary data block according to the sub-vectors, merge the sub-vectors output after the preset number of iterative calculations, and use the merged output vector as the second summary information.

[0156] Specifically, the summary calculation based on the restored data file is the same as step S1, and the iterative calculation formula is formula (1)-(15), which will not be repeated here.

[0157] Further, in step S8, judging whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information includes:

[0158] The first restoration summary information is compared with the second restoration summary information. If the first restoration summary information and the second restoration summary information are different, it is determined that the data file has been tampered with.

[0159] In some embodiments, reference Figure 6 , and also provides a watermark marking and extraction device for data files, comprising:

[0160] A first summary calculation module 201, configured to perform summary calculation based on the original data file to obtain original summary information;

[0161] A character conversion module 202, configured to convert the original summary information into a character string having the same format as the original data file, to obtain an original summary information character string;

[0162] The watermark generation module 203 is used to use the agreed watermark key as a seed, adopt a random algorithm to convert each character in the original summary information string into a random integer, and perform binary conversion on the random integer to generate a watermark;

[0163] The marking module 204 is used to mark the generated watermark into the original data file to obtain a marked file;

[0164] The watermark extraction module 205 is used to extract the watermark from the mark file according to the position of the watermark mark when extracting the watermark, and obtain the restored data file;

[0165] Restoration module 206, used to restore the extracted watermark to obtain first restored summary information;

[0166] A second summary calculation module 207 performs summary calculation based on the restored data file to obtain second restored summary information;

[0167] The tampering judgment module 208 is used to judge whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information.

[0168] Furthermore, the format of the data file is a database file or an Easy Language file.

[0169] Furthermore, the first summary calculation module 201 performs summary calculation based on the original data file to obtain original summary information, including:

[0170] Initialization vector;

[0171] Split the initialized vector into multiple sub-vectors and assign an initial value to each sub-vector;

[0172] Fill the original data file so that the length of the filled data file is an integer multiple of the length of the initialized vector;

[0173] Divide the filled data file according to the length of the initialized vector to obtain primary data blocks of corresponding lengths;

[0174] Dividing the primary data block into blocks to obtain secondary data blocks;

[0175] Perform a preset number of iterative calculations on each secondary data block according to the sub-vectors, merge the sub-vectors output after the preset number of iterative calculations, and use the merged output vector as the original summary information.

[0176] Furthermore, the first summary calculation module 201 fills the original data file so that the length of the filled data file is an integer multiple of the length of the initialized vector, including:

[0177] Obtain the length of the original data file, and convert the length into a 64-bit binary representation;

[0178] 1 and the 64-bit binary representation are added to the end of the original data file, and 0 is filled between 1 and the 64-bit binary representation, so that the length of the filled data file is an integer multiple of the length of the initialized vector.

[0179] Furthermore, the watermark generation module 203 uses the agreed watermark key as a seed and adopts a random algorithm to convert each character in the original summary information string into a random integer, including:

[0180] Perform a bitwise exclusive OR operation on each character in the original summary information string and the seed to generate the random integer.

[0181] Furthermore, the marking module 204 marks the generated watermark into the original data file to obtain a marked file, including:

[0182] Insert the binary string of each character corresponding to the generated watermark into each agreed position of the original data file;

[0183] When the generated watermark is inserted, insert the end mark at the end position of the watermark;

[0184] Traverse and insert each binary string into the original data file. When the binary character is 1, replace it with a placeholder.

[0185] Furthermore, the watermark extraction module 205 extracts the watermark from the mark file according to the position of the watermark mark to obtain the restored data file, including:

[0186] Traversing the tag file, extracting binary strings from each agreed position, and when a placeholder is detected, recording the character as 1;

[0187] When the terminator is detected, the extracted binary strings are combined to obtain the extracted watermark and the restored data file.

[0188] Furthermore, the restoration module 206 performs restoration processing on the extracted watermark to obtain first restoration summary information, including:

[0189] Convert the binary string in the extracted watermark into an integer;

[0190] Restoring the converted integer according to the watermark key to obtain a restored summary information character string;

[0191] The format of the restoration summary information character string is converted to obtain first restoration summary information.

[0192] Furthermore, the tampering judgment module 208 judges whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information, including:

[0193] The first restoration summary information is compared with the second restoration summary information. If the first restoration summary information and the second restoration summary information are different, it is determined that the data file has been tampered with.

[0194] The watermark marking and extraction method and device for data files provided in the above embodiments have at least the following beneficial effects:

[0195] (1) The summary information obtained by performing a series of transformations based on the summary calculation of the original data file is used as a watermark. On the one hand, it is more concealed and difficult to detect, and on the other hand, it is difficult to crack, thereby improving the security and reliability of data file transmission;

[0196] (2) Generate a binary string watermark and replace 1 with a non-display placeholder when inserting the watermark, further improving the concealment without interfering with the data file, thus ensuring the integrity and accuracy of the original data file;

[0197] (3) The calculated summary information is used as the basis for watermarking and tampering judgment, which can more accurately determine whether the data file has been tampered with, further ensuring the security of data file transmission.

[0198] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A watermark marking and extraction method for data files, characterized in that: include: Perform summary calculation based on the original data file to obtain original summary information; Converting the original summary information into a character string having the same format as the original data file to obtain an original summary information character string; Using the agreed watermark key as a seed, converting each character in the original summary information string into a random integer using a random algorithm, and performing binary conversion on the random integer to generate a watermark; Mark the generated watermark into the original data file to obtain a marked file; When extracting the watermark, the watermark is extracted from the mark file according to the position of the watermark mark to obtain the restored data file; Performing restoration processing on the extracted watermark to obtain first restoration summary information; Performing summary calculation based on the restored data file to obtain second restored summary information; Whether the data file has been tampered with is determined according to the first restoration summary information and the second restoration summary information.

2. The method according to claim 1, characterized in that The format of the data file is a database file or an Easy Language file.

3. The method according to claim 1, characterized in that Perform summary calculation based on the original data file to obtain the original summary information, including: Initialization vector; Split the initialized vector into multiple sub-vectors and assign an initial value to each sub-vector; Fill the original data file so that the length of the filled data file is an integer multiple of the length of the initialized vector; Divide the filled data file according to the length of the initialized vector to obtain primary data blocks of corresponding lengths; Dividing the primary data block into blocks to obtain secondary data blocks; Perform a preset number of iterative calculations on each secondary data block according to the sub-vectors, merge the sub-vectors output after the preset number of iterative calculations, and use the merged output vector as the original summary information.

4. The method according to claim 3, characterized in that The original data file is padded so that the length of the padded data file is an integer multiple of the length of the initialized vector, including: Obtain the length of the original data file, and convert the length into a 64-bit binary representation; 1 and the 64-bit binary representation are added to the end of the original data file, and 0 is filled between 1 and the 64-bit binary representation, so that the length of the filled data file is an integer multiple of the length of the initialized vector.

5. The method according to claim 1, characterized in that The agreed watermark key is used as a seed, and each character in the original summary information string is converted into a random integer using a random algorithm, including: Perform a bitwise exclusive OR operation on each character in the original summary information string and the seed to generate the random integer.

6. The method according to claim 1, characterized in that Mark the generated watermark into the original data file to obtain the marked file, including: Insert the binary string corresponding to each random integer in the generated watermark into each agreed position of the original data file; When the generated watermark is inserted, insert the end mark at the end position of the watermark; Traverse and insert each of the binary strings into the original data file, and when the binary character is 1, replace it with a placeholder.

7. The method according to claim 6, characterized in that According to the position of the watermark mark, the watermark is extracted from the mark file to obtain the restored data file, including: Traversing the tag file, extracting binary strings from each agreed position, and when a placeholder is detected, recording the character as 1; When the terminator is detected, the extracted binary strings are combined to obtain the extracted watermark and the restored data file.

8. The method according to claim 1, characterized in that The extracted watermark is restored to obtain first restored summary information, including: Convert the binary string in the extracted watermark into an integer; Restoring the converted integer according to the watermark key to obtain a restored summary information character string; The format of the restoration summary information character string is converted to obtain first restoration summary information.

9. The method according to any one of claims 1 to 8, characterized in that: Judging whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information includes: The first restoration summary information is compared with the second restoration summary information. If the first restoration summary information and the second restoration summary information are different, it is determined that the data file has been tampered with.

10. A watermark marking and extraction device for data files, characterized in that: include: A first summary calculation module, used to perform summary calculation based on the original data file to obtain original summary information; A character conversion module, used for converting the original summary information into a character string having the same format as the original data file, to obtain an original summary information character string; A watermark generation module, used to use the agreed watermark key as a seed, adopt a random algorithm to convert each character in the original summary information string into a random integer, and perform binary conversion on the random integer to generate a watermark; A marking module is used to mark the generated watermark into the original data file to obtain a marked file; A watermark extraction module is used to extract the watermark from the mark file according to the position of the watermark mark when extracting the watermark, so as to obtain a restored data file; A restoration module, used for performing restoration processing on the extracted watermark to obtain first restoration summary information; A second summary calculation module performs summary calculation based on the restored data file to obtain second restored summary information; The tampering judgment module is used to judge whether the data file has been tampered with according to the first restoration summary information and the second restoration summary information.

Citation Information

Patent Citations

  • Embedding and Extraction Method of Digital Watermark in Text Document

    CN103310130B

  • Watermark embedding and extracting method based on docx format document

    CN114637972A