Transform-based file encryption transmission method
Through the file encryption and transmission method based on Transformer, the file is converted into images and encrypted and decrypted using OCR and image denoising models, the problem of insufficient traditional encryption algorithms in complex network environments is solved, and a large amount of image and text information is realized. efficient and secure transfer of files.
Patent Information
- Application Number
- CN202411349919.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-31
AI Technical Summary
When the existing file encryption transmission technology faces complex network environments and advanced persistent threats, the encryption strength and decryption efficiency of traditional encryption algorithms are insufficient, and the semantic information transmission is ignored, making it difficult to effectively protect files containing a large amount of image and text information. .
Using the file encryption transmission method based on Transformer, the file content is converted into multiple images, and the text information and non-text information are encrypted and decrypted using the Transformer-based OCR model and image denoising model respectively. Through the partial text information and non-text information of the image Separation, segmentation, encoding and decoding of text information realizes semantic transmission of data.
While ensuring information encryption, it realizes information restoration while providing an efficient and secure solution for file transfer scenarios containing a large number of image and text information, improving the difficulty and security of information transmission.
Smart Images

Figure CN119232853A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security and image processing technology, in particular to image recognition and encryption transmission technology realized by deep learning technology, and specifically to a file encryption transmission method based on Transformer. Background Art
[0002] With the acceleration of digital transformation, file transfer has become an indispensable part of daily business operations. In the existing technology, file encryption transmission mainly relies on traditional encryption algorithms, such as AES, RSA, etc. Although these algorithms guarantee data security to a certain extent, their encryption strength and decryption efficiency face challenges in the face of complex network environments and advanced persistent threats (APT). In addition, the existing technology for file transfer processing often only targets the file data itself, while ignoring the information transmission at the semantic level, that is, the file itself is no longer transmitted, but the visual information of the file is extracted, the file is converted into a visual image, and the information is encrypted using the structured characteristics of the image content, which greatly increases the difficulty of information cracking.
[0003] OCR (Optical Character Recognition) technology is a method of converting text in an image into an editable and searchable text format. It obtains text information on an image through optical input methods such as scanning and video recording. OCR technology is widely used in document digitization, license plate recognition, bank check processing and other fields. There are many ways to implement OCR, including traditional image processing methods and deep learning-based methods.
[0004] Deep learning technologies represented by Transformer have been widely used in computer vision and natural language processing in recent years. Transformer and its variants have become one of the most important model architectures in deep learning. Transformer is a deep learning model first proposed in 2017. Its core innovation is the self-attention mechanism, which enables the model to handle long-distance dependency problems in sequence data and process all elements in the sequence in parallel, thereby greatly improving training efficiency. The self-attention mechanism allows the model to directly establish dependencies between any two positions in the sequence without waiting for information to be gradually transmitted. Another key feature of Transformer is that it uses multi-head attention, which means that the model learns information in parallel in different representation subspaces. This increases the expressive power of the model, enabling it to capture richer sequence features.
[0005] The Transformer model consists of an encoder and a decoder. The encoder converts the input sequence into a continuous representation, and the decoder generates the target sequence based on the encoder's output and previous outputs. In the self-attention layer, each position calculates the attention score with all other positions, which determines how much attention should be given to other positions when generating the output of the current position. This mechanism enables the model to capture complex patterns and relationships in the sequence.
[0006] Transformer has a wide range of applications in computer vision, and has many variants in areas such as image detection, image classification, and image segmentation. Summary of the invention
[0007] Aiming at the problems existing in the existing file encryption transmission technology, the present invention proposes a file encryption transmission method based on Transformer.
[0008] The present invention is achieved through the following technical solutions:
[0009] A file encryption transmission method based on Transformer, characterized in that: the file content is converted into multiple images, and the images are encrypted and decrypted respectively for text information and non-text information of the image through an encoder and a decoder based on an OCR model and an image denoising model of Transformer; wherein the OCR model based on Transformer is used to encrypt and decrypt text information, and the image denoising model based on Transformer is used to encrypt and decrypt non-text information.
[0010] The file encryption transmission method based on Transformer of the present invention specifically comprises the following steps:
[0011] S1 file imaging;
[0012] The file is opened by the visualization software at the sending end, and the screen content is automatically stored as an image by the screenshot tool. If the visualization content exceeds one screen size, multiple images are stored until the file content is included;
[0013] S2 separation of text and non-text;
[0014] All text information in the image is detected, and the type of text is determined to prepare for the subsequent morpheme determination; non-text information is filled with background, and the largest connected area is obtained in the image of the non-text area, and the average value of pixels in the area is used as the background filling pixel;
[0015] Segmentation and position coding of S3 text image blocks;
[0016] According to the preset image width and height Wunit ,H unit , the text area is divided into multiple image blocks, each image block contains a certain amount of text information; the image block cannot be divided into any morpheme; the position of each image block is encoded;
[0017] S4 encoding and encryption;
[0018] The non-text information is input into the Transformer-based image denoising model in the form of an image. The output result of the encoder part of the Transformer model can be regarded as a data encryption process and is encoded.
[0019] The text information is input into the Transformer-based OCR model in the form of image blocks; the encoder part of the Transformer encodes all image blocks to achieve data encryption; the position code corresponding to each image block is combined with the encoding result of the image block to form an encrypted data packet of the text part;
[0020] After the non-text information and text information are encrypted separately, they are transmitted together from the sending end to the receiving end;
[0021] S5 decoding and file restoration;
[0022] The non-text information is decoded by the decoder based on the Transformer image denoising model to restore the original image background without text information. bg ;
[0023] The text information is decoded by the decoder based on the Transformer OCR model to obtain the text information; based on the position encoding, the text information can be obtained corresponding to the image. bg The parsed text is redrawn to the image background I bg superior;
[0024] The same operation is performed on all image blocks, combining the text information with the non-text image to achieve the recovery of the image information.
[0025] Furthermore, in step S2, a morpheme is the smallest meaningful unit in a language, including: a Chinese character, a complete English word, and a punctuation mark.
[0026] Furthermore, in step S3, the image block cannot be divided into any morpheme by scaling and translating the image block where characters exist at the edge of the image block.
[0027] The method for scaling and translating an image block having characters at the edge of the image block includes:
[0028] When the image block does not contain any text information, the image block is not processed; when the edge of the image block divides a morpheme, the width or height of the image block is reduced so that it just avoids the morpheme at the edge, and then the image block is upsampled to the standard size W after reduction. unit ,H unit , the scaling information is recorded as r x ,r y , respectively represent the image width and height scaling ratios; when the block in front of an image block is scaled, the image block needs to be offset accordingly to seamlessly connect to the edge of the previous image block, and the shifted pixels are recorded as offset x ,offset y , respectively represent the translation pixels in the width and height directions of the image; when the length of an image block exceeds the limit of the original image, in order to ensure the uniform size of the input image, the redundant part of the image is filled with zeros;
[0029] The above method is used to divide the original image into blocks; the position change information of each image block is recorded as the position code of the image block, that is, a vector pos = (x, y, r x ,r y ,offset x ,offset y ), where x, y are the image coordinate positions of the upper left corner origin of the image block corresponding to the original image; each image block records the corresponding position code.
[0030] Beneficial effects of the present invention: The present invention does not adopt any traditional encryption and decryption algorithm, but uses the image to carry the visual information of the original file, further divides the visual information into a text part and a non-text part, and uses different model algorithms to process the two parts. Among them, a Transformer-based image denoising algorithm is adopted for the non-text part, and a Transformer-based OCR algorithm is adopted for the text part. Both algorithms are based on Transformer, and encryption uses the Transformer encoder as an encryption operator, and the Transformer decoder as a decryption operator. The method of the present invention is not based on the original file data, but realizes the semantic transmission of data by regenerating visual information. While ensuring the encryption of information, it also realizes the restoration of information. It is particularly suitable for file transmission scenarios containing a large amount of image and text information, and provides a new technical solution for the field of information security. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION
[0032] The present invention is further described below in conjunction with specific implementation methods. The specific implementation methods are further descriptions of the principles of the present invention and do not limit the present invention in any way. Technologies that are the same or similar to the present invention do not exceed the scope of protection of the present invention.
[0033] The present invention discloses a file encryption transmission method based on Transformer, which is characterized by: converting the file content into multiple images, and encrypting and decrypting the text information and non-text information of the image respectively through an encoder and a decoder based on an OCR model and an image denoising model of Transformer; wherein the OCR model based on Transformer is used for encrypting and decrypting the text information, and the image denoising model based on Transformer is used for encrypting and decrypting the non-text information.
[0034] The specific method is described as follows:
[0035] 1. Document imaging;
[0036] The file is opened by a specific visualization software at the sending end, and the screen content is automatically stored as an image using a screenshot tool. When the visualization content exceeds one screen size, multiple images are stored until the file content is included. This process ensures that the file content is stored in the form of an image, providing a basis for subsequent processing.
[0037] 2. Separation of text and non-text;
[0038] Using mature text detection algorithms, all text parts of the image are detected, and the type of text, such as Latin letters, Chinese characters, etc., can be determined to prepare for the subsequent morpheme judgment. The non-text part is filled with background to eliminate text information and ensure the independence of non-text information in subsequent processing. The largest connected area is obtained in the image of the non-text area, and the average value of the pixels in the area is used as the background filling pixel.
[0039] 3. Segmentation and position coding of text image blocks;
[0040] According to the preset width and height of the image, it is divided into W unit ,H unit , so as to divide the text area into multiple image blocks, each of which contains a certain amount of text information; and the image blocks cannot separate any morphemes.
[0041] Morpheme is a linguistic concept, which refers to the smallest meaningful unit in a language. For example, a Chinese character is a morpheme, and a complete word (not an independent letter) in English is a morpheme. In order to avoid information loss caused by a morpheme being at the edge of two adjacent image blocks, it is necessary to scale and translate the image blocks with characters at the edge of the blocks. The same principle applies to the width and height of the image blocks. There are several cases of block division:
[0042] When an image block does not include any text information, the image block is not allowed to be processed.
[0043] When the edge of an image block divides a morpheme, the width or height of the image block is reduced so that it just avoids the morpheme at the edge. After the reduction, the image block is upsampled to the standard size W unit ,H unit , the scale information is recorded as r x ,r y , respectively represent the scaling ratio of the image width and height.
[0044] When the block in front of a certain image block is scaled, the current image block needs to be offset accordingly to seamlessly connect to the edge of the previous image block. The pixels shifted are recorded as offset x ,offset y , respectively represent the translation pixels in the width and height directions of the image.
[0045] When the length of an image block exceeds the limit of the original image, in order to ensure the uniform size of the input image, the excess part of the image is filled with zeros.
[0046] The above principles can be used to divide the original image into blocks.
[0047] The position change information of each image block is recorded as the position code of the image block, which is a vector pos = (x, y, r x ,r y ,offset x ,offset y ), where x, y are the image coordinate positions of the upper left corner origin of the image block corresponding to the original image.
[0048] Each image block records the corresponding position code, so the position can be accurately restored even after the image block is processed and transmitted independently.
[0049] 4. Coding and encryption;
[0050] The non-text part is input into the Transformer-based image denoising model in the form of an image, and the output result of the encoder part of the model can be regarded as a data encryption process. This process not only removes the noise in the image, but also realizes the preliminary encryption of the image, enhancing the security during the transmission process.
[0051] The text image blocks are input into the Transformer-based OCR model, and the encoder part of the model encodes all image blocks to achieve data encryption.
[0052] The position code corresponding to each image block does not need to be input into the Transformer. The position code is combined with the encoding result of the image block to form the final encrypted data packet of the text part.
[0053] After the non-text and text parts are encrypted separately, they are transmitted together from the sending end to the receiving end.
[0054] 5. Decoding and file restoration;
[0055] The non-text part is decoded by the decoder of the Transformer-based image denoising model to restore the original image background without text information. bg .
[0056] The text part is decoded by the decoder based on the Transformer OCR model to obtain the text information. Based on the position encoding, the text information can be obtained corresponding to the image. bg The parsed text is redrawn to the image background I bg superior.
[0057] The same operation is performed on all image blocks, combining the text information with the non-text image, and finally realizing the recovery of the image information.
[0058] The file encryption transmission method based on Transformer of the present invention adopts file visualization information extraction and text and non-text separation technology. The method of the present invention no longer adopts the traditional file encryption and decryption method, no longer transmits the file itself, but extracts the visualization information of the file; first, the file is converted into multiple images, and the image itself does not directly participate in the transmission, but through text detection, the image is divided into two major parts: text and non-text, and the non-text part image is a new image obtained by filling the text part area with the image background.
[0059] The file encryption transmission method based on Transformer of the present invention adopts the method of dividing text image blocks and recording position codes. Considering that the size of the image may be large, processing the whole image may result in insufficient resolution in the area with smaller text, thereby affecting the effect of OCR. And because the input of the Transformer model of OCR has a preset size. Therefore, in the present invention, the original image is divided into blocks according to the dimensional size of the model input, and when the image block does not contain text, it is not processed. To ensure the normal transmission of information, the image block cannot divide any morpheme. When the edge of the image block just divides a morpheme, the image block size is reduced so that its edge will not divide any morpheme, and then upsampled to the standard image block size to avoid the loss of morpheme information at the edge. The image can finally be divided into multiple image blocks, and the position of each image block in the original image and the information on whether the image block is scaled are recorded as image position codes, which will be used by the data receiving end to recover the data.
[0060] The Transformer-based file encryption transmission method of the present invention adopts an encoder based on the Transformer-based image denoising and OCR model for data encryption.
[0061] In the present invention, the text part and the non-text part are respectively input into two Transformer-based models. The text part adopts Transformer-based OCR, and the non-text part adopts Transformer-based image denoising model.
[0062] The output of the Transformer encoder is used as the encrypted data.
[0063] The file encryption transmission method based on Transformer of the present invention uses the decoder of Transformer and the inverse transformation of the text part and the non-text part to realize data recovery. The encryption result includes text and non-text parts. The receiving end recovers the non-text image and text information through the decoding of Transformer, wherein the text part information is combined with the position coding of the image block for inverse transformation, and the text is drawn into the image to realize the regeneration of the image, thereby achieving the purpose of data decryption and recovery.
[0064] The file encryption transmission method based on Transformer of the present invention uses the encoder of the image denoising model to encrypt non-text information, and the encoder of the OCR model to encrypt text information; accordingly, the decoder of the image denoising model is used to decrypt non-text information, and the decoder of the OCR model is used to decrypt text information, and finally the visual data can be restored. The present invention regards the encoder as an encryption operation, the encoding output of the encoder as an encryption result, and the decoder can be regarded as a decoder, thereby realizing the encryption and decryption of data.
Claims
1. A file encryption transmission method based on Transformer, characterized in that: The file content is converted into multiple images. The images are encrypted and decrypted respectively for text information and non-text information through the encoder and decoder of the Transformer-based OCR model and image denoising model. Among them, the Transformer-based OCR model is used to encrypt and decrypt text information, and the Transformer-based image denoising model is used to encrypt and decrypt non-text information.
2. The file encryption transmission method based on Transformer according to claim 1 is characterized in that The following steps are involved: S1 file imaging; The file is opened by the visualization software at the sending end, and the screen content is automatically stored as an image by the screenshot tool. If the visualization content exceeds one screen size, multiple images are stored until the file content is included; S2 separation of text and non-text; All text information in the image is detected, and the type of text is determined to prepare for the subsequent morpheme determination; non-text information is filled with background, and the largest connected area is obtained in the image of the non-text area, and the average value of pixels in the area is used as the background filling pixel; Segmentation and position coding of S3 text image blocks; According to the preset image width and height W unit ,H unit , the text area is divided into multiple image blocks, each image block contains a certain amount of text information; the image block cannot be divided into any morpheme; the position of each image block is encoded; S4 encoding and encryption; Non-text information is input into the Transformer-based image denoising model in the form of images; The output of the encoder part of the Transformer model can be regarded as a data encryption process and encoded; Text information is input into the Transformer-based OCR model in the form of image blocks; The encoder part of the Transformer encodes all image blocks to achieve data encryption; the position code corresponding to each image block is combined with the encoding result of the image block to form an encrypted data packet of the text part; After the non-text information and text information are encrypted separately, they are transmitted together from the sending end to the receiving end; S5 decoding and file restoration; The non-text information is decoded by the decoder based on the Transformer image denoising model to restore the original image background without text information. bg ; The text information is decoded by the decoder of the Transformer-based OCR model to obtain the text information; Based on the position coding, the text information can be mapped to the image. bg The parsed text is redrawn to the image background I bg superior; The same operation is performed on all image blocks, combining the text information with the non-text image to achieve the recovery of the image information.
3. The file encryption transmission method based on Transformer according to claim 2 is characterized in that: In step S2, a morpheme is the smallest meaningful unit in a language, including a Chinese character, a complete English word, and a punctuation mark.
4. The file encryption transmission method based on Transformer according to claim 3 is characterized in that: In step S3, the image block cannot be divided into any morpheme by scaling and translating the image block where characters exist at the edge of the image block.
5. The file encryption transmission method based on Transformer according to claim 4 is characterized in that: The method for scaling and translating an image block having characters at the edge of the image block includes: When the image block does not contain any text information, the image block is not processed; when the edge of the image block divides a morpheme, the width or height of the image block is reduced so that it just avoids the morpheme at the edge, and then the image block is upsampled to the standard size W after reduction. unit ,H unit , the scaling information is recorded as r x ,r y , respectively represent the image width and height scaling ratios; when the block in front of an image block is scaled, the image block needs to be offset accordingly to seamlessly connect to the edge of the previous image block, and the shifted pixels are recorded as offset x ,offset y , respectively represent the translation pixels in the width and height directions of the image; when the length of an image block exceeds the limit of the original image, in order to ensure the uniform size of the input image, the redundant part of the image is filled with zeros; The above method is used to divide the original image into blocks; the position change information of each image block is recorded as the position code of the image block, that is, a vector pos = (x, y, r x ,r y ,offset x ,offset y ), where x, y are the image coordinate positions of the upper left corner origin of the image block corresponding to the original image; Each image block records the corresponding position code.
