Two-dimensional code encryption method, decryption method and system based on invisible watermark
By embedding encrypted information of invisible watermarks in the QR code, the problems of QR code information leakage and insufficient watermark robustness are solved, and a high security and concealment QR code encryption and decryption system is realized.
Patent Information
- Application Number
- CN202510185919.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-13
AI Technical Summary
QR codes are easy to read by anyone, and there is a risk of information leakage; existing watermarking technology often lacks robustness in real shooting scenes.
The QR code encryption method based on invisible watermarks is adopted to encrypt the information to be encrypted through a symmetric encryption algorithm, and an invisible digital watermark is added to the ordinary QR code using a generative adversarial network model, embedding the key and encrypted information.
It significantly improves the security and concealment of QR code information, enhances the anti-interference ability and extraction of watermark recognition, and ensures that keys and encrypted information can be extracted accurately and reliably under common shooting conditions.
Smart Images

Figure CN120145343A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of two-dimensional code encryption, and specifically, to a method and system for encrypting and decrypting two-dimensional codes based on invisible watermarks, as well as a corresponding computer terminal and computer-readable storage medium. Background Art
[0002] A two-dimensional code (Quick Response Code, also known as a quick response matrix code) is also called a two-dimensional barcode, which refers to a barcode that extends another dimension with readability on the basis of a one-dimensional barcode. It uses black and white rectangular patterns to represent binary data, and the information contained therein can be obtained after being scanned by a device.
[0003] Two-dimensional codes use four standardized encoding modes (numeric, alphanumeric, byte (binary), and Japanese (Shift_JIS)) to store data. Two-dimensional codes are widely used in mobile phone code reading operations around the world. Two-dimensional codes have faster reading speed and larger information storage capacity than ordinary one-dimensional barcodes, and there is no need to align the barcode straight with the scanner during scanning like one-dimensional barcodes. Compared with one-dimensional barcodes that only record data in terms of width, both the length and width of two-dimensional codes record data. At the same time, two-dimensional codes also have "positioning points" and "error correction mechanisms" that one-dimensional barcodes do not have. The error correction mechanism means that even if not all of the two-dimensional code is recognized or the two-dimensional code is damaged, the information on the two-dimensional code can still be correctly restored. Two-dimensional codes usually have specific positioning marks, and the code reader can correctly identify and interpret them through the positioning marks. Therefore, two-dimensional codes can be recognized regardless of the reading direction. As a result, their application scope has been extended to include product tracking, item identification, document management, inventory marketing, etc.
[0004] Similar to the previous one-dimensional barcodes, two-dimensional codes are widely used in commercial activities, especially in industries such as high-tech, storage and transportation, wholesale and retail, etc., which require inexpensive and fast identification of item information. In many countries and regions, barcodes that are as easy to generate and read as two-dimensional codes have become a convenient way of information exchange in life and are widely used in many fields such as identity recognition tags and mobile payments.
[0005] Digital watermarking refers to embedding specific information into a digital signal, which may be audio, pictures, videos, etc. If a signal with a digital watermark is copied, the embedded information will also be copied. Digital watermarks can be divided into visible watermarks and hidden watermarks. The former is a visible watermark, and the information it contains can be seen while viewing pictures or videos. Generally speaking, visible watermarks usually contain the name or logo of the copyright owner. The logo placed in the corner of the TV screen is also a type of visible watermark. Hidden watermarks are added to audio, pictures, or videos in the form of digital information, but they cannot be seen under normal circumstances. One of the important applications of hidden watermarks is to protect copyright, hoping to avoid or prevent unauthorized copying and duplication of digital media through this. The annotation information in digital photos can record information such as the time when the photo was taken, the aperture and shutter speed used, and even the brand of the camera. This is also one of the applications of digital watermarks.
[0006] Digital watermarking technology can also be classified by methods into: spatial domain (time domain) watermarks and transform domain watermarks. Among them, spatial domain watermarks are based on the fact that each pixel point is generally represented by eight bits, and they are arranged from the most significant bit (MSB) to the least significant bit (LSB) from right to left, representing the order of bit importance. Therefore, spatial domain watermarks can embed watermark information by changing the least sensitive LSB in each sampling point, making the watermark have a high degree of concealment. This is a simple and easy-to-implement method most commonly used to hide information in information hiding technology. However, its disadvantage is that it is easily maliciously damaged by illegal persons and is difficult to resist various attacks such as noise, compression processing, image processing, and cropping processing. Transform domain watermarks mainly convert the original image into the frequency domain and then add watermark information. Embedding the watermark into different frequency component signals can meet different requirements. When embedded in high-frequency signals, it is less likely to be detected by the human visual system. When embedded in low-frequency component signals, it is not easily damaged due to high energy.
[0007] Compared with the above traditional methods, deep neural networks can automatically extract the spatial information and depth information of images and perform non-linear fitting according to the given constraints, thereby generating a watermark image with better concealment, clarity, non-removability, and robustness than traditional digital watermarks. At the same time, the information hiding algorithm using deep neural networks and the idea of image reconstruction can also be more easily automated in implementation. However, the information hiding algorithm using deep neural networks and the idea of image reconstruction still has the following technical problems:
[0008] 1. Since two-dimensional codes are easily readable by anyone, there is a risk of information leakage;
[0009] 2. Existing watermarking technologies often lack robustness in real shooting scenarios. Summary of the Invention
[0010] In view of the above deficiencies in the prior art, the present invention provides a two-dimensional code encryption method, a decryption method and a system based on invisible watermark, and also provides a corresponding computer terminal and a computer-readable storage medium.
[0011] According to one aspect of the present invention, there is provided a two-dimensional code encryption method based on invisible watermark, including:
[0012] Encrypting the information to be encrypted according to a key through a symmetric encryption algorithm to obtain encrypted information;
[0013] Generating a common two-dimensional code by using the encrypted information;
[0014] Providing an encoder model trained based on a generative adversarial network, and adding an invisible digital watermark hiding the key to the common two-dimensional code through the encoder model by using the key and the common two-dimensional code to obtain an encrypted two-dimensional code with an invisible watermark, thereby completing the encryption process.
[0015] Preferably, the above method further includes:
[0016] Adding distortion simulation information to the encrypted two-dimensional code with an invisible watermark for simulating the noise caused in the process of obtaining the two-dimensional code in the real world.
[0017] According to another aspect of the present invention, there is provided a two-dimensional code decryption method based on invisible watermark corresponding to the above two-dimensional code encryption method based on invisible watermark, including:
[0018] Providing a decoder model trained based on a generative adversarial network, and decoding the encrypted two-dimensional code with an invisible watermark through the decoder model to obtain the key hidden in the invisible watermark and the common two-dimensional code;
[0019] Generating encrypted information by using the common two-dimensional code;
[0020] Restoring the encrypted information to the information to be encrypted according to the key through a symmetric encryption algorithm to complete the decoding process.
[0021] According to a third aspect of the present invention, there is provided a two-dimensional code encryption and decryption system based on invisible watermark, including: an encryption process module and / or a decryption process module; wherein:
[0022] The encryption process module includes:
[0023] An information encryption sub-module, which is used for encrypting the information to be encrypted according to a key through a symmetric encryption algorithm to obtain encrypted information; generating a common two-dimensional code by using the encrypted information;
[0024] A watermark encryption sub-module, which is used to provide an encoder model trained based on a generative adversarial network. Using the key and a normal two-dimensional code, the encoder model is used to add an invisible digital watermark hiding the key to the normal two-dimensional code to obtain an encrypted two-dimensional code with an invisible watermark;
[0025] The decryption process sub-module includes:
[0026] A watermark decryption sub-module, which is used to provide a decoder model trained based on a generative adversarial network. Using the decoder model to decode the encrypted two-dimensional code with an invisible watermark to obtain the key hidden in the invisible watermark and the normal two-dimensional code;
[0027] An information decryption sub-module, which uses the normal two-dimensional code to generate encrypted information; according to the key, through a symmetric encryption algorithm, the encrypted information is restored to the information to be encrypted;
[0028] Preferably, the above system further includes:
[0029] A noise layer module, which is arranged between the watermark encryption sub-module and the watermark decryption sub-module. The noise layer module adds distortion simulation information to the encrypted two-dimensional code output by the watermark encryption sub-module to simulate the noise caused in the process of obtaining the two-dimensional code in the real world.
[0030] According to the fourth aspect of the present invention, a computer terminal is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it can be used to execute the method described in the present invention, or run the system described above in the present invention.
[0031] According to the fifth aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it can be used to execute the method described above in the present invention, or run the system described above in the present invention.
[0032] Due to the adoption of the above technical solutions, compared with the prior art, the present invention has at least one of the following beneficial effects:
[0033] The two-dimensional code encryption method, decryption method and system based on invisible watermark provided by the present invention adopt symmetric encryption and invisible watermark technology. By encrypting the information to be encrypted and embedding the key and the encrypted information into the watermark and the two-dimensional code respectively for storage, it is ensured that the information in the two-dimensional code is only visible to users with the ability to recognize the invisible watermark, significantly improving the security and concealment of the information.
[0034] The QR code encryption method, decryption method, and system based on invisible watermark provided by the present invention introduce a noise layer simulation mechanism during the training process of the deep neural network. By introducing a noise layer module to simulate the real noise environment, the anti-interference ability of watermark recognition and the robustness of the system to extract the watermark are enhanced, ensuring that the key and encrypted information can be accurately and reliably extracted under common shooting conditions.
[0035] The QR code encryption method, decryption method, and system based on invisible watermark provided by the present invention implement a QR code with an invisible watermark to the human eye. The additional information independent of the QR code contained in the invisible watermark can encrypt and decrypt the information in the QR code. At the same time, it has a decoder that can extract the information contained in the invisible watermark from the image taken by the camera and decrypt the QR code simultaneously.
[0036] Compared with traditional QR codes, the QR code encryption method, decryption method, and system based on invisible watermark provided by the present invention can embed more information through digital watermarking, so as to encrypt and embed the information to be hidden into the QR code. When decrypting, the hidden information can be obtained through the information of the watermark and the encrypted information in the QR code. At the same time, it can ensure that the information encoded in the image QR code can be correctly parsed in common shooting environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] By reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings, other features, objects, and advantages of the present invention will become more apparent:
[0038] Figure 1 It is a flowchart of the working process of the QR code encryption method based on invisible watermark in a preferred embodiment of the present invention.
[0039] Figure 2 It is a flowchart of the working process of the QR code decryption method based on invisible watermark in a preferred embodiment of the present invention.
[0040] Figure 3 It is a schematic diagram of the training of the invisible watermark encoder and decoder in a preferred embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0041] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made. These all belong to the protection scope of the present invention.
[0042] In view of the above problems in the prior art, an embodiment of the present invention provides a two-dimensional code encryption method based on invisible watermarking.
[0043] Specifically, as Figure 1 shown, the two-dimensional code encryption method based on invisible watermarking provided by this embodiment may include:
[0044] S1. According to the key, use a symmetric encryption algorithm to encrypt the information to be encrypted to obtain encrypted information;
[0045] S2. Use the encrypted information to generate a normal two-dimensional code;
[0046] S3. Provide an encoder model trained based on a generative adversarial network. Use the key and the normal two-dimensional code, and through the encoder model, add an invisible digital watermark hiding the key to the normal two-dimensional code to obtain an encrypted two-dimensional code with an invisible watermark, thus completing the encryption process.
[0047] In some preferred embodiments, the above method may further include:
[0048] S4. Add distortion simulation information to the encrypted two-dimensional code with an invisible watermark to simulate the noise caused during the process of obtaining the two-dimensional code in the real world.
[0049] In some preferred embodiments, for the above S1, according to the key, use a symmetric encryption algorithm to encrypt the information to be encrypted to obtain encrypted information, which may further include:
[0050] S11. Through a symmetric encryption algorithm, split the plaintext of the information to be encrypted into several plaintext blocks;
[0051] S12. Fill the last plaintext block according to the set filling method;
[0052] S13. Use the key to encrypt each plaintext block into a ciphertext block;
[0053] S14. Concatenate all the ciphertext blocks to obtain the final encrypted information.
[0054] In some preferred embodiments, for the above S2, using the encrypted information to generate a normal two-dimensional code, it may further include: converting the encrypted information into a two-dimensional code through a two-dimensional code generator.
[0055] In some preferred embodiments, for the above S3, providing an encoder model trained based on a generative adversarial network, it may further include:
[0056] S31. Provide a generative adversarial network;
[0057] S32. Using the QR code image and the random key dataset as inputs, feature extraction and fusion of the QR code image and the key information are performed through a generative adversarial network, so that the image and the information are encoded in the feature space;
[0058] S33. With the goal of reconstructing an encrypted QR code image with an invisible watermark that is close to the original QR code image, the generative adversarial network is continuously learned and the network parameters are updated until the iteration number is reached or the optimal solution of the network parameters is obtained, and an encoder model is trained;
[0059] S34. The input of the encoder model is a QR code image containing encrypted information and its corresponding key information, and the output is an encrypted QR code with an invisible watermark hiding the key.
[0060] In the encryption method and decryption method provided in the above embodiments of the present invention:
[0061] In the process of encrypting information in the encryption method, symmetric encryption algorithm is used to achieve encryption. Because compared with the digest algorithm, the symmetric encryption algorithm is reversible and can ensure that private information is not leaked. The key is the basis for the symmetric encryption algorithm to achieve encryption and decryption. The symmetric encryption algorithm is called symmetric because this type of algorithm uses the same key for encrypting and decrypting the plaintext. When the symmetric encryption algorithm encrypts the plaintext, it does not encrypt the entire plaintext into a single ciphertext segment at once. Instead, the plaintext is split into individual plaintext blocks. These plaintext blocks are processed by the symmetric encryption algorithm using the key to generate individual ciphertext blocks. These ciphertext blocks are concatenated together to form the final encrypted block result.
[0062] The process executed by the decryption method is the reverse process of the encryption method. In the process of decrypting information in the decryption method, the ciphertext and the key transmitted from the decoder model are received. First, according to the rules of the symmetric encryption algorithm, the ciphertext is split into individual ciphertext blocks. These ciphertext blocks are processed by the symmetric encryption algorithm using the key to generate individual plaintext blocks. Finally, these plaintext blocks are concatenated together to obtain the encrypted information to be transmitted.
[0063] In the process of encrypting the watermark, the encoder model adopted by the encoding method consists of a generative convolutional neural network. The input of the entire encoder model is two strings, one is the QR code information and the other is the key information. First, a QR code image (with a size of M*N*3) is generated using the QR code message. At the same time, the key message is preprocessed through a dense layer to convert its size to M*N*1, because this preprocessing applied to the key message helps the system converge. Then it is concatenated with the QR code image to generate an M*N*4 image, which is input into the decoder model. During training, the encoder model takes a large number of QR code images and random keys as input, extracts features and fuses the QR code images and key information, thereby encoding the information and images in the feature space. At the same time, with the optimization goal of reconstructing a QR code image with an invisible watermark that is visually close to the original QR code image to the human eye, it continuously learns how to update the network parameters and finally obtains the optimal solution of the network parameters.
[0064] In the process of decrypting the watermark, the output image of the encoder model can be input into the decoder model after passing through the noise layer.
[0065] The above-mentioned noise layer can enhance the robustness of the network to the distortion caused during the transmission process to resist the small-angle changes introduced during the capture and correction of the encoded image and the color difference caused by the printer camera. In a preferred embodiment, a camera is provided to capture the output of the encoder (on the screen or printed). The distortion simulation information added by the noise layer includes: perspective distortion, motion and defocus blur, color processing, noise, JPEG compression distortion simulation.
[0066] Based on the same inventive concept, an embodiment of the present invention also provides a method for decrypting a QR code based on an invisible watermark corresponding to any one of the above-mentioned embodiments of the method for encrypting a QR code based on an invisible watermark of the present invention.
[0067] Specifically, as Figure 2 shown, the method for decrypting a QR code based on an invisible watermark provided by this embodiment may include:
[0068] M1, providing a decoder model trained based on a generative adversarial network, using the decoder model to decode the encrypted QR code with an invisible watermark to obtain the key and the ordinary QR code hidden in the invisible watermark;
[0069] M2, using the ordinary QR code to generate encrypted information;
[0070] M3, according to the key, through a symmetric encryption algorithm, restoring the encrypted information to the information to be encrypted, and completing the decoding process.
[0071] In some preferred embodiments, the above-mentioned M1 provides a decoder model trained based on a generative adversarial network, and may further include:
[0072] Provide a generative adversarial network, use the QR code image with an invisible watermark added with distortion simulation information as input, train the generative adversarial network, and use the recovery of the key hidden in the invisible watermark and the ordinary QR code as the optimization goal. Continuously learn and update the network parameters of the generative adversarial network until the number of iterations is reached or the optimal solution of the network parameters is obtained, and train the decoder model.
[0073] In some preferred embodiments, for the encrypted QR code with an invisible watermark in the above-mentioned M1 during the decoding of the encrypted QR code with an invisible watermark, it is an encrypted QR code added with distortion simulation information.
[0074] In some preferred embodiments, the above-mentioned M2 uses an ordinary QR code to generate encrypted information, and may further include: directly using a QR code decoder to read the QR code information from the encrypted QR code with an invisible watermark, that is, the encrypted information. In some preferred embodiments, the above-mentioned M3, according to the key, restores the encrypted information to the information to be encrypted through a symmetric encryption algorithm, and may further include:
[0075] Through the symmetric encryption algorithm, split the encrypted information ciphertext into several ciphertext blocks, then use the key to decrypt each ciphertext block into a plaintext block, and finally splice all the plaintext blocks to restore the encrypted information to the information to be encrypted.
[0076] Based on the same inventive concept, an embodiment of the present invention also provides a QR code encryption system based on an invisible watermark.
[0077] Specifically, the QR code encryption and decryption system based on an invisible watermark provided by this embodiment may include: an encryption process module and / or a decryption process module; where:
[0078] The encryption process module includes:
[0079] The information encryption sub-module is used to encrypt the information to be encrypted through a symmetric encryption algorithm according to the key to obtain encrypted information; use the encrypted information to generate an ordinary QR code;
[0080] The watermark encryption sub-module is used to provide an encoder model trained based on a generative adversarial network, and use the key and the ordinary QR code to add an invisible digital watermark hiding the key to the ordinary QR code through the encoder model to obtain an encrypted QR code with an invisible watermark;
[0081] The decryption process sub-module includes:
[0082] A watermark decryption sub-module, which is used to provide a decoder model trained based on a generative adversarial network, and use the decoder model to decode the encrypted two-dimensional code with an invisible watermark to obtain the key and the ordinary two-dimensional code hidden in the invisible watermark;
[0083] An information decryption sub-module, which uses the ordinary two-dimensional code to generate encrypted information; according to the key, through a symmetric encryption algorithm, the encrypted information is restored to the information to be encrypted;
[0084] In some preferred embodiments, the above system may further include: a noise layer module; where:
[0085] The noise layer module is arranged between the watermark encryption sub-module and the watermark decryption sub-module, and adds distortion simulation information to the encrypted two-dimensional code output by the watermark encryption sub-module through the noise layer module, which is used to simulate the noise caused in the process of obtaining the two-dimensional code in the real world.
[0086] An information encryption sub-module: The encryption module uses a symmetric encryption algorithm to encrypt the transmission information into encrypted information according to the key, so as to ensure that the transmission information is not leaked.
[0087] An information decryption sub-module: The encryption module uses a symmetric encryption algorithm to decrypt the encrypted information into transmission information according to the key.
[0088] A watermark encryption sub-module, which provides an encoder model composed of a convolutional neural network. Through training with a large number of two-dimensional code images and random keys as inputs, it continuously learns how to update network parameters, so as to embed the key information into the two-dimensional code image and generate a two-dimensional code with an invisible watermark containing the key information;
[0089] A watermark decryption sub-module, which provides a decoder model composed of a convolutional neural network, and takes the two-dimensional code with an invisible watermark obtained by photographing through the camera of a mobile device such as a mobile phone as an input, and parses the key information and encrypted information therein;
[0090] A noise layer model, which is placed between the encoder / decoder during training. In order to simulate the noise caused by real-world shooting, we added perspective distortion, motion and defocus blur, color processing, noise, and JPEG compression distortion simulation to the noise layer to enhance the robustness of the network to the distortion noise caused during transmission.
[0091] It should be noted that the steps in the method provided by the present invention can be implemented by using the corresponding components in the system, etc. Those skilled in the art can refer to the technical solution of the system to implement the step flow of the method, or refer to the technical solution of the method to implement the composition of the system. That is, the embodiments in the system and the embodiments in the method can be understood as preferred examples of each other, and will not be elaborated here.
[0092] The following further elaborates in detail on the technical solutions provided in the above embodiments of the present invention in combination with a specific application example.
[0093] As Figure 1 shown, it is the working process of the encryption method. The encryption process is as follows: The information to be encrypted is encrypted by a key and the Advanced Encryption Standard algorithm (symmetric encryption algorithm) to obtain the encrypted information. Then, the ordinary QR code generated from the encrypted information and the key pass through the encoder model, which is a model trained based on the generative adversarial network. This model is used to add a watermark invisible to the human eye to the QR code, thereby obtaining an encrypted QR code with an invisible watermark. The symmetric encryption algorithm is used in the encryption process. Now, the Advanced Encryption Standard (AES) algorithm is taken as an example for illustration. The AES algorithm mainly consists of the following processes: 1. Split the plaintext into several plaintext blocks according to 128 bits. 2. Fill the last plaintext block according to the selected padding method. 3. Each plaintext block is encrypted into a ciphertext block by an AES encryptor and a key. 4. Concatenate all the ciphertext blocks to form the final ciphertext result.
[0094] As Figure 2 shown, it is the working process of the decryption method. The decryption process is as follows: The encrypted QR code with an invisible watermark is captured by the camera of a mobile device such as a mobile phone and input into the decoder model, which is a model obtained by training the generative adversarial network. This model is used to decode the encrypted QR code to obtain the key hidden in the invisible watermark. Then, the encrypted QR code is decoded by a QR code decoder to obtain the encrypted information. Finally, the encrypted information is restored to the information to be encrypted through the key and the Advanced Encryption Standard algorithm. The process executed by the decryption algorithm is the reverse process of the encryption algorithm. The decryption algorithm mainly consists of the following processes: 1. Split the ciphertext into several ciphertext blocks according to 128 bits. 2. Each ciphertext block is decrypted into a plaintext block by an AES encryptor and a key. 3. Concatenate all the plaintext blocks to form the final ciphertext result.
[0095] As Figure 3 shown, it is a schematic diagram of the training process of the encoder model and the decoder model.
[0096] Encoder Model: The entire encoder model is composed of a convolutional neural network. The input of the entire encoder model is two strings, one is the QR code information and the other is the key information. First, the QR code message is used to generate a QR code image (with a size of M*N*3). At the same time, the key message is preprocessed through a dense layer to convert its size to M*N*1, because this preprocessing applied to the key message helps the system converge. Then it is concatenated with the QR code image to generate an M*N*4 image, which is input into the decoder model. During training, the encoder model takes a large number of QR code images and random keys as input, extracts features and fuses the QR code images and key information, thereby encoding the information and images in the feature space. At the same time, with the goal of reconstructing a QR code image with an invisible watermark that is visually close to the original QR code image to optimize, it continuously learns how to update the network parameters and finally obtains the optimal solution of the network parameters.
[0097] Decoder Model: The output image of the encoder model is input into the decoder model after passing through the noise layer. The noise layer can enhance the robustness to resist small angular changes introduced during the capture and correction of the encoded image and color differences caused by printers and cameras. During training, the decoder model takes the QR code with an invisible watermark passing through the noise layer as input, with the goal of recovering the key information hidden in the invisible watermark to optimize, continuously learns how to update the network parameters, and finally obtains the network parameters that can achieve the optimal key information recovery rate.
[0098] Noise Layer: To enhance the robustness of the network to the distortion noise caused during transmission, assume that there is a camera that can capture the QR code image generated by the encoder on the screen or printed out. To simulate the noise that occurs in real-world shooting, perspective distortion, motion and defocus blur, color processing, noise, and JPEG compression distortion simulation are added to the encrypted QR code through the noise layer.
[0099] By comparing the plaintext information (information to be encrypted) QR code, the ciphertext information (encrypted information) QR code with an invisible watermark, and the ciphertext information QR code, it can be concluded that the human eye cannot distinguish whether the watermark is embedded.
[0100] An embodiment of the present invention also provides a computer terminal, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it can be used to execute the method of any one of the above embodiments of the present invention, or, run the system of any one of the above embodiments of the present invention.
[0101] Optionally, a memory for storing programs; the memory may include volatile memory (e.g., random-access memory, such as static random-access memory (SRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), etc.); the memory may also include non-volatile memory, such as flash memory. The memory is used to store computer programs (such as application programs and functional modules for implementing the above methods), computer instructions, etc. The above computer programs, computer instructions, etc. can be stored in partitions in one or more memories. And the above computer programs, computer instructions, data, etc. can be called by the processor.
[0102] A processor for executing the computer programs stored in the memory to implement each step in the methods or each module in the systems involved in the above embodiments. For specific details, reference can be made to the relevant descriptions in the previous method and system embodiments.
[0103] The processor and the memory can be of an independent structure or an integrated structure integrated together. When the processor and the memory are of an independent structure, the memory and the processor can be coupled and connected through a bus.
[0104] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it can be used to execute the method of any one of the above embodiments of the present invention, or to run the system of any one of the above embodiments of the present invention.
[0105] Among them, the computer-readable medium includes computer storage media and communication media. The communication media includes any medium that facilitates the transfer of computer programs from one place to another. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer. An exemplary storage medium is coupled to the processor, enabling the processor to read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. Additionally, the ASIC can be located in a user device. Of course, the processor and the storage medium can also exist as discrete components in a communication device.
[0106] The QR code encryption method, decryption method, and system provided in the above embodiments of the present invention are used to generate QR codes with invisible watermarks and perform encryption and decryption. The encryption method encrypts the transmission information into encrypted information according to the key, thus ensuring that the transmission information is not leaked. The encryption module uses a symmetric encryption algorithm to split the plaintext into several plaintext blocks, then fills the last plaintext block according to the selected padding method, and then encrypts each plaintext block into a ciphertext block using the key. Finally, all the ciphertext blocks are concatenated to form the final ciphertext result. The decryption method decrypts the encrypted information into transmission information according to the key. The decryption module splits the ciphertext into several ciphertext blocks, and then decrypts each ciphertext block into a plaintext block using the key. Finally, all the plaintext blocks are concatenated to form the final plaintext result. The encoder model is used to embed the key information into the QR code image to generate a QR code with an invisible watermark containing the key information. The structure of the encoder is a generative adversarial network model, and the input is a Figure 2 key information corresponding to the QR code image containing the encrypted information. The encoder takes a large number of QR code images and random keys as inputs, extracts and fuses the features of the QR code images and the key information, thereby encoding the information and the image in the feature space. At the same time, with the goal of reconstructing a QR code image with an invisible watermark that is visually close to the original QR code image to optimize, it continuously learns how to update the network parameters, and finally obtains the optimal solution of the network parameters. The decoder model is used to parse the key information and the encrypted information from the encoded QR code with an invisible watermark. Considering that the present invention is applied in multiple practical application scenarios such as medical, retail, cultural and creative, and industrial, the input of the decoder is generally a QR code with an invisible watermark obtained by photographing with a camera of a mobile device such as a mobile phone. During training, the decoder takes the QR code with an invisible watermark passing through the noise layer as the input, and with the goal of restoring the information of the invisible watermark to optimize, continuously updates the network parameters, and finally obtains the network parameters that can reach the optimal. The noise layer simulates the noise caused by shooting in the real world, and adds perspective distortion, motion and defocus blur, color processing, noise, JPEG compression distortion simulation to the noise layer to enhance the robustness of the network to the distortion noise caused during the transmission process.
[0107] The QR code encryption method, decryption method, and system based on invisible watermark provided in the above embodiments of the present invention can be applied to many fields as follows: (1) Medical field. In this field, a lot of medical device information and patient personal information are stored through QR codes. The present invention can be used to encrypt such important information to avoid the leakage of medical device information or patient personal information. (2) Cultural and creative field. In this field, by encrypting the QR code and then decoding the ordinary QR code and the encrypted QR code with invisible watermark, two kinds of information can be obtained to achieve the dual use of one code. (3) Retail field. In this field, by encrypting the merchant's payment QR code, it can be avoided that someone takes advantage of the opportunity to cover the merchant's payment QR code with their own QR code, causing economic losses to the merchant. (4) Industrial field. In this field, for the property protection and anti-counterfeiting traceability of products, the anti-counterfeiting traceability and property protection of products can be realized by adding the information hidden in the invisible watermark to the QR code in the commodity.
[0108] Matters not described in detail in the above embodiments of the present invention are all well-known technologies in the art.
[0109] The specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various deformations or modifications within the scope of the claims, which do not affect the essence of the present invention.
Claims
1. A two-dimensional code encryption method based on invisible watermark, characterized in that: include: According to the key, the information to be encrypted is encrypted by a symmetric encryption algorithm to obtain the encrypted information; Generate a common QR code using the encrypted information; An encoder model obtained through generative adversarial network training is provided. The key and the ordinary two-dimensional code are used to add an invisible digital watermark containing the key to the ordinary two-dimensional code through the encoder model to obtain an encrypted two-dimensional code with the invisible watermark, thereby completing the encryption process.
2. According to the two-dimensional code encryption method based on invisible watermarking in claim 1, it is characterized in that: The method of encrypting the information to be encrypted by a symmetric encryption algorithm according to the key to obtain the encrypted information includes: Using a symmetric encryption algorithm, the plaintext information to be encrypted is split into several plaintext blocks; Fill the last plaintext block according to the set filling method; Using the key, encrypt each plaintext block into a ciphertext block; Concatenate all ciphertext blocks to get the final encrypted information.
3. According to the two-dimensional code encryption method based on invisible watermarking in claim 1, it is characterized in that: The encoder model provided is obtained by training based on a generative adversarial network, including: Providing a generative adversarial network; Using the two-dimensional code image and the random key data set as input, the generative adversarial network is used to extract and fuse the features of the two-dimensional code image and the key information, so that the image and the information are encoded in the feature space; Taking the reconstruction of an encrypted two-dimensional code image with an invisible watermark close to the original two-dimensional code image as the optimization goal, the generative adversarial network is continuously learned and the network parameters are updated until the number of iterations is reached or the optimal solution of the network parameters is obtained, and the encoder model is trained; The input of the encoder model is a two-dimensional code image containing encrypted information and its corresponding key information, and the output is an encrypted two-dimensional code with an invisible watermark hiding the key.
4. The invisible watermark-based two-dimensional code encryption method according to any one of claims 1 to 3, characterized in that: Also includes: Distortion simulation information is added to the encrypted two-dimensional code with the invisible watermark to simulate the noise caused by the process of obtaining the two-dimensional code in the real world.
5. A two-dimensional code decryption method based on an invisible watermark corresponding to the two-dimensional code encryption method based on an invisible watermark according to any one of claims 1 to 3, characterized in that: include: A decoder model obtained by training a generative adversarial network is provided, and the encrypted two-dimensional code with the invisible watermark is decoded by using the decoder model to obtain the key hidden in the invisible watermark and the ordinary two-dimensional code; Generate encrypted information using the common QR code; According to the key, through the symmetric encryption algorithm, the encrypted information is restored to the information to be encrypted, completing the decoding process.
6. The two-dimensional code decryption method based on invisible watermark according to claim 5 is characterized in that: Also includes any one or more of the following: -The provision of a decoder model based on generative adversarial network training includes: A generative adversarial network is provided. A two-dimensional code image with an invisible watermark to which distorted simulated information is added is used as input. The generative adversarial network is trained to restore the key and the common two-dimensional code hidden in the invisible watermark as an optimization goal. The generative adversarial network is continuously learned and the network parameters are updated until the number of iterations is reached or the optimal solution of the network parameters is obtained, and a decoder model is obtained by training. - the encrypted two-dimensional code with an invisible watermark in the decoding of the encrypted two-dimensional code with an invisible watermark by using the decoder model is an encrypted two-dimensional code with distortion simulation information added; - The step of restoring the encrypted information to the information to be encrypted by using a symmetric encryption algorithm according to the key includes: The encrypted information ciphertext is split into several ciphertext blocks by a symmetric encryption algorithm, and then each ciphertext block is decrypted into a plaintext block using a key, and finally all the plaintext blocks are concatenated to restore the encrypted information to the information to be encrypted.
7. A two-dimensional code encryption and decryption system based on invisible watermark, characterized in that: include: An encryption process module and / or a decryption process module; wherein: The encryption process module comprises: An information encryption submodule, which is used to encrypt the information to be encrypted by a symmetric encryption algorithm according to a key to obtain encrypted information; and to generate a common QR code using the encrypted information; A watermark encryption submodule, which is used to provide an encoder model obtained by training based on a generative adversarial network, and to add an invisible digital watermark with a hidden key to the ordinary two-dimensional code through the encoder model using the key and the ordinary two-dimensional code, so as to obtain an encrypted two-dimensional code with an invisible watermark; The decryption process submodule comprises: A watermark decryption submodule, which is used to provide a decoder model obtained by training based on a generative adversarial network, and use the decoder model to decode the encrypted two-dimensional code with the invisible watermark to obtain the key hidden in the invisible watermark and the ordinary two-dimensional code; The information decryption submodule generates encrypted information using the common two-dimensional code; according to the key, the encrypted information is restored to the information to be encrypted through a symmetric encryption algorithm.
8. The invisible watermark-based two-dimensional code encryption and decryption system according to claim 7 is characterized in that: Also included: a noise floor module; wherein: The noise layer module is arranged between the watermark encryption submodule and the watermark decryption submodule. The noise layer module adds distortion simulation information to the encrypted two-dimensional code output by the watermark encryption submodule to simulate the noise caused by the process of obtaining the two-dimensional code in the real world.
9. A computer terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it can be used to perform the method described in any one of claims 1 to 6, or to run the system described in any one of claims 7 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it can be used to perform the method described in any one of claims 1 to 6, or to run the system described in any one of claims 7 to 8.