Method and device for adding and applying text watermark
By presetting configuration rules and calculating text fingerprints in the text watermark addition method to select watermark characters and locations, the problem of easy discovery and clearing of text watermarks in the prior art is solved, and the effect of easy implementation and easy evidence collection of text watermarks is achieved.
Patent Information
- Application Number
- CN202210106921.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-01-28
AI Technical Summary
In the prior art, the text watermark addition method is easily discovered and cleared by potential infringers, and the implementation is complex and it is difficult to effectively solve the infringement problem.
By preset configuration rules, including watermark character selection rules and rules for adding watermark positions, calculate text fingerprints and select watermark characters and positions based on them, and add watermarks to text. This method does not rely on special characters, and the content of the watermark dots is special, and can be restored and reproduced by fair algorithms and configuration parameters.
It realizes the easy implementation and easy evidence collection of text watermarks, and is not easy to be discovered and cleared by potential infringers, improving the ability to identify and verify infringement of text content.
Smart Images

Figure CN114547562B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of IT and software development, and in particular to a method and device for realizing text watermark addition and application. Background Art
[0002] Currently, algorithms and methods for adding watermarks to information text already exist.
[0003] Related prior art: A method for embedding and extracting text watermarks, publication number: CN 110414194A, which implements a method for adding invisible UTF characters to a text watermark, but has the following problems: it is easily discovered and removed by potential infringers; A method and device for embedding and detecting digital text watermarks, publication number: CN 110322386A, which uses a chaotic algorithm to set color differences for specific texts in a specific text environment, but has the following problems: it is too complicated to implement, has limited usage conditions, and is easily discovered and removed by potential infringers.
[0004] Therefore, there is an urgent need to develop a method for watermarking ordinary text that is easy to implement, easy to obtain evidence, and not easy to be discovered and removed by potential infringers. Summary of the invention
[0005] The technical problem to be solved by the present invention is how to realize a method for a common text watermark which is easy to implement, easy to obtain evidence, and not easy to be discovered and removed by potential infringers.
[0006] To solve the above technical problems, according to a first aspect of the present invention, a method for adding a text watermark is provided, comprising the following steps: S1, presetting configuration rules, the configuration rules including watermark character selection rules and watermark adding position rules; S2, preparing text, receiving the original text to be watermarked, performing preprocessing, obtaining and outputting the intermediate text; S3, calculating the text fingerprint, using the text fingerprint algorithm to calculate the text fingerprint of the intermediate text, obtaining and outputting the text fingerprint string; S4, calculating the text watermark selection offset, selecting a reference word in the intermediate text according to the watermark character selection rule, the reference word is used as a reference for watermark character confirmation, and outputting the watermark word; S5, adding a text watermark, adding the watermark word to the text according to the watermark adding position rule, and outputting the text after the watermark is added.
[0007] According to an embodiment of the present invention, the watermark character selection rule may include: S41, cutting a segment of the text fingerprint character string calculated in step S3; S42, converting the segment of the character string into a decimal number; S43, taking the remainder of the decimal number modulo the length of the intermediate text to obtain a reference character selection offset, and determining that the character corresponding to the offset position is the watermark character reference character, and the offset calculation formula is:
[0008] S=X mod L
[0009] Among them, S represents the reference word selection offset, X refers to the decimal number converted from the string, L is the length of the intermediate text, and mod represents the remainder.
[0010] According to an embodiment of the present invention, the method of intercepting a segment of the text fingerprint character string in the above step S41 includes intercepting N characters in the text, where N is a natural number.
[0011] According to an embodiment of the present invention, the watermark character selection rule may further include: S44, using a homophone dictionary to obtain a homophone of the reference character from the reference character, and selecting any homophone as the watermark character; or S44 is selecting the reference character as the watermark character. The user can select the desired watermark character selection rule by himself, and is not limited to this.
[0012] According to an embodiment of the present invention, the rule for adding a watermark position may include: S51, determining a watermark adding offset A, where A is between 1 and the middle text length L.
[0013] According to an embodiment of the present invention, the preprocessing in the above step S2 may include: removing all punctuation marks, spaces, control characters, and invisible UTF characters in the original text.
[0014] According to an embodiment of the present invention, the text fingerprint algorithm in the above step S3 includes: any one of MD5, SHA-1, SHA-128, and SHA-256 algorithms.
[0015] According to a second aspect of the present invention, there is provided a method for applying a text watermark, comprising the following steps: a text content outputter publicly announces text watermark adding rules, the rules including a watermark algorithm and configuration parameters; when publicly accessible text content involves an original ownership dispute, the text content outputter calculates the original text according to the notarized watermark algorithm and configuration parameters to generate an output watermarked text; the output watermarked text is compared with the disputed text to resolve the dispute.
[0016] According to a third aspect of the present invention, there is provided a device for adding a text watermark, comprising: a configuration rule unit for presetting configuration rules, the configuration rules including watermark character selection rules and watermark position addition rules; a text preprocessing unit for preparing text, receiving an original text to be watermarked, performing preprocessing, obtaining and outputting an intermediate text; a text fingerprint calculation unit for calculating a text fingerprint, using a text fingerprint algorithm to calculate the text fingerprint on the intermediate text, obtaining and outputting a text fingerprint character string; an offset selection unit for calculating a text watermark selection offset, selecting a reference character in the intermediate text according to the watermark character selection rule, the reference character being used as a reference for watermark character confirmation, and outputting the watermark character; and a text watermark addition unit for adding a text watermark, adding the watermark character to the text according to the watermark position addition rule, and outputting the watermarked text.
[0017] According to an embodiment of the present invention, the watermark character selection rule may include: intercepting a segment of the text fingerprint string output by the text fingerprint calculation unit, converting the segment of the string into a decimal number, and then taking the remainder of the decimal number modulo the intermediate text length to obtain a reference character selection offset, and determining that the character corresponding to the offset position is the watermark character reference character, and the offset calculation formula is:
[0018] S=X mod L
[0019] Among them, S represents the reference word selection offset, X refers to the decimal number converted from the string, and L is the length of the intermediate text.
[0020] According to an embodiment of the present invention, the method of intercepting a segment of the text fingerprint character string may include intercepting certain N characters in the text, where N is a natural number.
[0021] According to an embodiment of the present invention, the watermark character selection rule may also include: using a homophone dictionary to obtain a homophone of a reference character from a reference character, and selecting any homophone as a watermark character; or selecting a reference character as a watermark character. The user may select the desired watermark character selection rule, which is not limited to this.
[0022] According to an embodiment of the present invention, the rule for adding a watermark position may include: determining a watermark adding offset A, where A is between 1 and the middle text length L.
[0023] According to an embodiment of the present invention, the function of the text preprocessing unit may include: removing all punctuation marks, spaces, control characters, and invisible UTF characters in the original text.
[0024] According to an embodiment of the present invention, the text fingerprint algorithm used by the text fingerprint calculation unit may include any one of MD5, SHA-1, SHA-128, and SHA-256.
[0025] According to a fourth aspect of the present invention, there is provided an apparatus for applying text watermarks, comprising: a publicizing unit, used by a text content outputter to publicize text watermarking rules, the rules comprising a watermarking algorithm and configuration parameters; a generating unit, used to generate and output watermarked text, when publicly accessible text content involves an original ownership dispute, the text content outputter calculates the original text according to the notarized watermarking algorithm and configuration parameters, and generates and outputs watermarked text; and a comparing unit, used to compare the output watermarked text with the disputed text, thereby resolving the dispute.
[0026] According to a fifth aspect of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned text watermark adding method.
[0027] According to a sixth aspect of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned text watermark application method.
[0028] According to a seventh aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above-mentioned text watermark adding method when executed by a processor.
[0029] According to an eighth aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above-mentioned text watermark application method when executed by a processor.
[0030] Compared with the prior art, the technical solution provided by the embodiments of the present invention can at least achieve the following beneficial effects:
[0031] 1. Compared with other text watermark technologies, this technical patent does not rely on special characters such as invisible UTF (Unicode Transformation Format) characters, etc., because these special characters can be automatically removed in batches by the infringer using rules, and even in the case of infringement, the evidence cannot be locked; only by adopting the solution of the present invention, based on ordinary text with similar content, and with special features in the content of the watermark point, can it be restored and reproduced by relying on the algorithm and configuration parameters that have been justified in advance. The technical solution implemented by the present invention is superior to other technical solutions in terms of feasibility and difficulty in circumvention.
[0032] 2. When applying, we (the content output party) will notarize the above-mentioned ordinary text watermarking method and management configuration in advance. When publicly accessible text content involves disputes over original ownership, we will generate output text for the original text according to the notarized watermark algorithm and configuration parameters, and compare it with the disputed text to resolve the dispute.
[0033] 3. This solution can be used to verify the originality of the output text content, and can be output in the form of an API (Application Programming Interface). The retention and re-output of the partner's content during the process can be verified through the API.
[0034] 4. The present invention provides a method for quickly identifying and verifying infringements of text content, and can provide strong persuasive evidence in determining the original ownership of articles on social platforms such as WeChat public accounts, and in situations involving API output, ensure that partners or capability callers retain their own output content, and ensure that the output to a third party meets their own requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present invention, but are not intended to limit the present invention.
[0036] Figure 1 is a flow chart of a method for adding a text watermark according to an embodiment of the present invention.
[0037] Figure 2 Schematic diagram of a text watermark adding device according to an embodiment of the present invention.
[0038] Figure 3 It is a schematic diagram of an example of adding a text watermark according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] Unless otherwise defined, the technical or scientific terms used herein shall have the common meanings understood by persons with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the patent application specification and claims of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one" or "a" do not indicate a quantity limitation, but indicate the existence of at least one.
[0041] Figure 1 is a flow chart of a method for adding a text watermark according to an embodiment of the present invention.
[0042] like Figure 1 As shown, according to the first aspect of the present invention, a method for adding a text watermark is provided, comprising the following steps: S1, presetting configuration rules, the configuration rules including watermark character selection rules and watermark position adding rules; S2, preparing text, receiving the original text to be watermarked, performing preprocessing, obtaining and outputting the intermediate text; S3, calculating the text fingerprint, using the text fingerprint algorithm to calculate the text fingerprint for the intermediate text, obtaining and outputting the text fingerprint string; S4, calculating the text watermark selection offset, selecting a reference word in the intermediate text according to the watermark character selection rules, the reference word is used as a reference for watermark character confirmation, and outputting the watermark word; S5, adding a text watermark, adding the watermark word to the text according to the watermark position adding rules, and outputting the text after the watermark is added. This method for adding a text watermark is easy to implement, easy to obtain evidence, and not easy to be discovered and removed by potential infringers.
[0043] According to one or some embodiments of the present invention, the watermark character selection rule includes: S41, cutting a segment of the text fingerprint character string calculated in step S3; S42, converting the segment of the character string into a decimal number; S43, taking the remainder of the decimal number modulo the length of the intermediate text to obtain a reference character selection offset, and determining that the character corresponding to the offset position is the watermark character reference character, and the offset calculation formula is:
[0044] S=X mod L
[0045] Among them, S represents the reference word selection offset, X refers to the decimal number converted from the string, L is the length of the intermediate text, and mod represents the remainder. Therefore, the corresponding relative reference word is determined by the offset obtained by the remainder, and the relative reference word is used as the input word for generating the watermark character.
[0046] According to one or some embodiments of the present invention, the method of intercepting a segment of the text fingerprint string in step S41 includes intercepting N characters in the text, where N is a natural number. The specific interception position can be preset or selected by the user.
[0047] According to one or some embodiments of the present invention, the watermark character selection rule further includes: S44, using a homophone dictionary to obtain a homophone of the reference character from the reference character, and selecting any homophone as the watermark character; or S44 is selecting the reference character as the watermark character. The user can select the desired watermark character selection rule by himself, which is not limited to this.
[0048] According to one or some embodiments of the present invention, the rule for adding a watermark position includes: S51, determining a watermark adding offset A, where A is between 1 and the middle text length L. Adding a watermark word to the text.
[0049] According to one or some embodiments of the present invention, the preprocessing in the above step S2 includes: removing all punctuation marks, spaces, control characters, invisible UTF characters, etc. in the original text. These special characters can be automatically removed in batches by the infringing party using rules, and after removal, it is convenient to lock evidence in subsequent processing.
[0050] According to one or some embodiments of the present invention, the text fingerprint algorithm in the above step S3 includes any one of MD5, SHA-1 (Secure Hash Algorithm 1, a cryptographic hash function designed by the National Security Agency of the United States and published by the National Institute of Standards and Technology (NIST) of the United States as the Federal Data Processing Standard (FIPS)), SHA-128, SHA-256, etc. The user can select the desired fingerprint algorithm by himself, without being limited to this.
[0051] Compared with other text watermark technologies, the technical solution of this embodiment does not rely on special characters such as invisible UTF (Unicode Transformation Format) characters, etc., because these special characters can be automatically removed in batches by the infringing party using rules, and even in the case of infringement, the evidence cannot be locked; only by adopting the solution of the present invention, based on ordinary text with similar content, and with special features in the content of the watermark point, can it be restored and reproduced by relying on the algorithm and configuration parameters that have been justified in advance. The technical solution implemented by the present invention is superior to other technical solutions in terms of feasibility and difficulty in circumvention.
[0052] Figure 2 Schematic diagram of a text watermark adding device according to an embodiment of the present invention.
[0053] According to a second aspect of the present invention, there is provided a method for applying a text watermark, comprising the following steps: a text content outputter publicly announces text watermark adding rules, the rules including a watermark algorithm and configuration parameters; when publicly accessible text content involves an original ownership dispute, the text content outputter calculates the original text according to the notarized watermark algorithm and configuration parameters to generate an output watermarked text; the output watermarked text is compared with the disputed text to resolve the dispute.
[0054] When the technical solution of this embodiment is applied, the party (the content outputter) shall notarize the above-mentioned ordinary text watermark adding method and management configuration in advance. When the publicly accessible text content involves a dispute over the original ownership, the party shall generate an output text for the original text according to the notarized watermark algorithm and configuration parameters, and compare it with the disputed text to resolve the dispute.
[0055] Figure 3 It is a schematic diagram of an example of adding a text watermark according to an embodiment of the present invention.
[0056] For example, when adding a text watermark, firstly, the configuration rules of the text watermark are preset, including the watermark character selection rules and the rules for adding the watermark position.
[0057] like Figure 3 As shown, if the original text "China Telecom Group Co., Ltd. Shanghai Branch" is processed, the intermediate text is obtained after processing: "China Telecom Group Co., Ltd. Shanghai Branch".
[0058] Then calculate the text fingerprint for the text, for example, for the intermediate text "China Telecom Group Co., Ltd. Shanghai Branch", for example, use the MD5 algorithm to obtain the text fingerprint string "f574976f87332ee83f49480ee25fb497".
[0059] Calculate the text watermark selection offset. Cut a section of the text fingerprint string of the intermediate text calculated above according to the pre-configuration, such as cutting the last 6 characters (the specific cutting position and length are in accordance with the pre-management configuration), convert the cut string into an integer value X, such as cutting the last 6 characters of the string in the above "f574976f87332ee83f49480ee25fb497", that is: "5fb497", convert the hexadecimal to decimal, and after conversion to an integer, X=6272151; the length of the intermediate text L is 17; take the remainder of X modulo the length of the intermediate text L, and obtain the reference word selection offset, denoted as S, and use mod (remainder function), that is, S=X mod L=6272151mod 17=1.
[0060] Add a text watermark. According to the calculated reference character offset S, add a watermark character to the original text. The application rule of the offset S is determined according to the management configuration. For example, the offset can be applied from the start of the original text. Non-ordinary texts (i.e., all the punctuation marks, spaces, control characters, invisible UTF characters, etc. excluded above) are not counted. In the above example, the offset S = 1, and the selected reference character is the first ordinary string "中". According to the management configuration, determine an added offset A (which should be between 1 and L, e.g., A = integer part of L / 2 = 8). Starting from the start of the reference character, add the offset A = 8, and add the watermark character at the 8th character after the reference character "中" in the original text. The watermark character can be the superimposed character of the reference character "中". Similarly, non-ordinary texts are not counted, and the output text "《中国电信集团股份中有限公司上海分公司》" is formed. The addition of the watermark is completed. Optionally, any homophone of the reference character such as "钟", "忠", "仲", etc. from the homophone dictionary can also be used as the watermark character.
[0061] According to the third aspect of the present invention, there is provided a device for adding a text watermark, including: a configuration rule unit for presetting configuration rules, where the configuration rules include a watermark character selection rule and a rule for adding the position of the watermark; a text preprocessing unit for preparing the text, receiving the original text to which the watermark is to be added, performing preprocessing, and obtaining and outputting an intermediate text; a text fingerprint calculation unit for calculating a text fingerprint, calculating the text fingerprint of the intermediate text using a text fingerprint algorithm, and obtaining and outputting a text fingerprint string; a selection offset unit for calculating a text watermark selection offset, selecting a reference character in the intermediate text according to the watermark character selection rule, where the reference character is used as a reference for watermark character confirmation, and outputting the watermark character; a text watermark addition unit for adding a text watermark, adding the watermark character to the text according to the rule for adding the position of the watermark, and outputting the text after adding the watermark.
[0062] According to one or some embodiments of the present invention, the watermark character selection rule includes: intercepting a section of the text fingerprint string output by the text fingerprint calculation unit, converting the section of the string into a decimal number, and then taking the remainder of the decimal number modulo the length of the intermediate text to obtain a reference character selection offset, and determining the character corresponding to the offset position as the watermark character reference. The offset calculation formula is:
[0063] S = X mod L
[0064] Wherein, S represents the reference character selection offset, X refers to the decimal number converted from the section of the string, and L is the length of the intermediate text.
[0065] According to one or some embodiments of the present invention, the method of intercepting a section of the text fingerprint string includes intercepting a certain N characters in the text, where N is a natural number.
[0066] According to one or some embodiments of the present invention, the watermark character selection rule further includes: using a homophone dictionary to obtain a homophone of the reference character from the reference character, and selecting any homophone as the watermark character; or selecting the reference character as the watermark character. The user can select the desired watermark character selection rule by himself, which is not limited to this.
[0067] According to one or some embodiments of the present invention, the rule for adding a watermark position includes: determining a watermark adding offset A, where A is between 1 and the middle text length L.
[0068] According to one or some embodiments of the present invention, the function of the text preprocessing unit includes: removing all punctuation marks, spaces, control characters, and invisible UTF characters in the original text.
[0069] According to one or some embodiments of the present invention, the text fingerprint algorithm used by the text fingerprint calculation unit includes: any one of MD5, SHA-1, SHA-128, and SHA-256 algorithms.
[0070] The device for adding text watermarks can be implemented by software and / or hardware. The technical solution of this embodiment can be used to verify the originality of the output text content, and can be output in the form of an API (Application Programming Interface). Through the API, the retention and re-output of the partner's content in the process can be verified.
[0071] According to a fourth aspect of the present invention, there is provided an apparatus for applying text watermarks, comprising: a publicizing unit, used by a text content outputter to publicize text watermarking rules, the rules comprising a watermarking algorithm and configuration parameters; a generating unit, used to generate and output watermarked text, when publicly accessible text content involves an original ownership dispute, the text content outputter calculates the original text according to the notarized watermarking algorithm and configuration parameters, and generates and outputs watermarked text; and a comparing unit, used to compare the output watermarked text with the disputed text, thereby resolving the dispute.
[0072] The present invention provides a method for quickly identifying and verifying infringements of text content, and can provide strong persuasive evidence in determining the original ownership of articles on social platforms such as WeChat public accounts, and in situations involving API output, ensure that partners or capability callers retain their own output content, and ensure that the output to a third party meets their own requirements.
[0073] According to a fifth aspect of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned text watermark adding method.
[0074] According to a sixth aspect of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned text watermark application method.
[0075] The electronic device is only an example and should not limit the functions and scope of use of the embodiments of the present invention. The electronic device is in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: one or more processors, a storage device, and a bus connecting different system components (including the storage device and the processor).
[0076] Electronic devices typically include a variety of computer-readable storage media. These media can be any available media that can be accessed by the electronic device, including volatile and non-volatile media, removable and non-removable media.
[0077] The storage device may include a computer-readable storage medium in the form of a volatile memory, such as a random access memory (RAM) and / or a cache memory. The electronic device may further include other removable / non-removable, volatile / non-volatile computer-readable storage media. By way of example only, the storage system may be used to read and write non-removable, non-volatile magnetic media.
[0078] According to a seventh aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above-mentioned text watermark adding method when executed by a processor.
[0079] According to an eighth aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above-mentioned text watermark application method when executed by a processor.
[0080] Of course, those skilled in the art can understand that when the program is executed by a processor, the technical solution of the text watermark adding method provided by any embodiment of the present invention can also be implemented.
[0081] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CDROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0082] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program codes. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0083] The above description is merely an exemplary embodiment of the present invention and is not intended to limit the protection scope of the present invention. The protection scope of the present invention is determined by the appended claims.
Claims
1. A method for adding a text watermark, comprising the following steps: S1. Preset configuration rules, wherein the configuration rules include watermark character selection rules and watermark position addition rules; S2, prepare text, receive the original text to be watermarked, perform preprocessing, obtain and output the intermediate text; S3, calculate the text fingerprint, use the text fingerprint algorithm to calculate the text fingerprint of the intermediate text, obtain and output the text fingerprint string; S4, selecting a reference character from the intermediate text according to the watermark character selection rule, the reference character being used as a reference for watermark character confirmation, and outputting the watermark character; S5, adding a text watermark, adding the watermark word to the text according to the rule of adding the watermark position, and outputting the text after adding the watermark, The watermark character selection rules include: S41, intercepting a section of the text fingerprint character string calculated in step S3; S42, converting the string into a decimal number; S43, taking the remainder of the decimal number modulo the length of the intermediate text to obtain a reference character selection offset, and determining that the character corresponding to the offset position is the watermark character reference character. The offset calculation formula is: S=X mod L Among them, S represents the reference word selection offset, X refers to the decimal number converted from the string, L is the length of the intermediate text, and mod represents the remainder.
2. The method of claim 1, wherein: The method of intercepting a segment of the text fingerprint string in step S41 includes intercepting N characters in the text fingerprint string. Wherein, N is a natural number.
3. The method of claim 1, wherein: The watermark character selection rules also include: S44, using a homophone dictionary, obtaining homophones of the reference character from the reference character, and selecting any homophone as the watermark character.
4. The method of claim 1, wherein: The watermark character selection rules also include: S44, selecting the reference word as the watermark word.
5. The method of claim 1, wherein: The rules for adding watermark positions include: S51. Determine the watermark adding offset A, where A is between 1 and the middle text length L.
6. The method of claim 1, wherein: The preprocessing in step S2 includes: removing all punctuation marks, spaces, control characters, and invisible UTF characters in the original text.
7. The method of claim 1, wherein: The text fingerprint algorithm in step S3 includes any one of MD5, SHA-1, SHA-128, and SHA-256.
8. A device for adding a text watermark, comprising: A configuration rule unit, used for presetting configuration rules, wherein the configuration rules include watermark character selection rules and watermark position adding rules; The text preprocessing unit is used to prepare the text, receive the original text to be watermarked, perform preprocessing, and obtain and output the intermediate text; A text fingerprint calculation unit is used to calculate the text fingerprint, calculate the text fingerprint by using the text fingerprint algorithm on the intermediate text, and obtain and output the text fingerprint character string; An offset selection unit is used to select a reference character from the intermediate text according to the watermark character selection rule, the reference character is used as a reference for watermark character confirmation, and output the watermark character; A text watermark adding unit is used to add a text watermark, add the watermark word to the text according to the watermark adding position rule, and output the text after the watermark is added. The watermark character selection rules include: A segment of the text fingerprint string output by the text fingerprint calculation unit is intercepted, and the segment of the string is converted into a decimal number. The decimal number is modulo the remainder of the intermediate text length to obtain the reference word selection offset, and the character corresponding to the offset position is determined as the watermark character reference word. The offset calculation formula is: S=X mod L Among them, S represents the reference word selection offset, X refers to the decimal number converted from the string, and L is the length of the intermediate text.
9. The device of claim 8, wherein: The method of intercepting a segment of the text fingerprint string includes intercepting certain N characters in the text fingerprint string, Wherein, N is a natural number.
10. The device according to claim 8, wherein: The watermark character selection rules also include: By using a homophone dictionary, homophones of the reference word are obtained from the reference word, and any homophone is selected as a watermark word.
11. The device of claim 8, wherein: The watermark character selection rules also include: The reference word is selected as the watermark word.
12. The device of claim 8, wherein: The rules for adding watermark positions include: Determine the watermark adding offset A, where A is between 1 and the middle text length L.
13. The device of claim 8, wherein: The functions of the text preprocessing unit include: removing all punctuation marks, spaces, control characters, and invisible UTF characters in the original text.
14. The device of claim 8, wherein: The text fingerprint algorithm used by the text fingerprint calculation unit includes: any one of MD5, SHA-1, SHA-128, and SHA-256 algorithms.
15. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the text watermark adding method as described in any one of claims 1-7.
16. A computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for adding a text watermark as claimed in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Digital text watermark embedding and detecting method and device
CN110322386A
Text watermark embedding and extracting method
CN110414194A
Contract anti-counterfeiting method based on mobile terminal fingerprint recognition
CN106919848A
High embedding rate data steganography device and steganography method based on compression coding
CN107623855A