Urine test strip image encryption method based on DES
Through the DES-based urine test strip image encryption method, the problem of insufficient correlation and security of adjacent pixels in urine test strip image transmission is solved, and efficient and safe images are achieved Encrypted transmission.
Patent Information
- Application Number
- CN202310000591.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-03
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2043-01-03
AI Technical Summary
In the field of medical image processing, especially in urine test strip image transmission, the prior art is difficult to effectively reduce the correlation between adjacent pixels of the image, resulting in insufficient image encryption speed and security, and cannot meet data in an open network environment Transmission security requirements.
Using DES-based urine test strip image encryption method, the encrypted image and the key image are XOR operation, combined with the 3DES algorithm and F-wheel function transformation, triple DES loop encryption is performed, the number of encryptions and the use of initialized vector IV is increased to ensure that The security and encryption rate of image data.
It realizes efficient encryption of urine test strip images, reduces the correlation of adjacent pixels, improves the security and attack resistance of image transmission, and is suitable for encrypted transmission of large data volumes.
Smart Images

Figure CN116055650B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of medical image processing, and in particular to a urine test paper image encryption method based on DES. Background Art
[0002] Mobile medical technology has flourished along with the computer boom. As a vivid information carrier, digital images are an important form of data transmission in the field of mobile medical care. In the field of medical diagnosis, protecting the privacy of user data is a focal issue. Therefore, how to ensure the security of image data transmission in an open network environment has become a core task that needs to be strengthened in the field. In recent years, the field of information encryption has derived a variety of encryption algorithms such as chaos encryption, scrambling encryption, and DNA encryption based on traditional encryption technology. These algorithms have their own advantages in information encryption speed, space occupancy, ciphertext complexity, noise resistance, and anti-attack. The difference between image file encryption and ordinary file encryption is that there is usually a relatively large correlation between adjacent pixels of the image. Image encryption not only makes the image unrecognizable, but also minimizes the correlation between adjacent pixels as much as possible. Summary of the invention
[0003] In order to reduce the correlation between adjacent pixels of urine test strip images, the present invention provides a DES-based urine test strip image encryption method with fast encryption speed and high security in view of the characteristics of urine test strip images such as high information redundancy and small data.
[0004] The technical solution for achieving the purpose of the present invention is:
[0005] A urine test paper image encryption method based on DES, comprising the following steps:
[0006] (1) Encrypt the image to be encrypted once: read the image to be encrypted and the key image, traverse the RGB values of the pixels of the image to be encrypted and the key image one by one, and convert them into binary files. Use the image key to perform an XOR operation with the encrypted image to obtain the binary data of the hidden information image;
[0007] (2) Encrypt the image using the 3DES algorithm: Obtain the binary data of the hidden message image in step (1), encrypt it block by block, divide the binary file into 64-bit binary blocks, perform IP substitution on the obtained binary blocks, obtain substitution binary block 2, and divide it into 32-bit L and R binary blocks as the plaintext to be encrypted;
[0008] (3) Encryption F-round function transformation: The plaintext R to be encrypted is input into the encryption F-round function transformation, and the expansion, XOR transformation, compression, and substitution operations are performed in sequence. After the L and R regions are swapped, the F-round function is cycled 16 times and the F-round function is encrypted.
[0009] (4) Triple DES cycle: loop through steps (2) to (3) three times to increase the number of encryptions and achieve triple security encryption.
[0010] The method for encrypting the image to be encrypted in step (1) comprises the following steps:
[0011] 1) Obtain the digital image to be encrypted, the key digital image, and the width and height of the digital image, and convert the digital image into a binary file;
[0012] 2) One-time encryption: Compare the sizes of the binary data generated by the digital image to be encrypted and the key digital image, and compare the sizes of the two binary files. If the sizes are different, return to the previous logic layer. If they are the same, perform an XOR operation to complete one-time encryption and output the binary file that is initially encrypted by the XOR operation of the key image; binary XOR operation formula:
[0013] .
[0014] The method for encrypting an image using the 3DES algorithm in step (2) comprises the following steps:
[0015] 1) Block division: Obtain the binary file that has completed the initial encryption from step (1) and divide it into 64-bit units. The DES algorithm structure limits the plaintext input to 64-bit. It is necessary to fill the last group in the above step that may not meet the 64-bit bit. Use the PKCS5Padding filling mode. Set the unit data size to len bytes, that is, before encryption, the data byte len is taken modulo 8, and the remainder is set to m. If m>0, then 8-m bytes are supplemented. The byte value is 8-m, that is, the number of bytes is supplemented by the number of bytes missing. The byte value is the number of supplemented bytes. If it is 0, 8 bytes are supplemented. When decrypting, take the last byte with a value of m, then delete m bytes from the end of the data, and the remaining data is the original text before encryption. After the grouping is completed, start encryption in 64-bit groups;
[0016] 2) Group concatenation: Before entering the F-round function, set an initialization vector IV to perform an XOR operation with each plaintext group, and then perform an XOR operation on the encrypted ciphertext and the next plaintext group to be encrypted, so that the plaintext groups are connected in series, improving the security of encryption, and preparing to transfer the group data to the IP replacement box;
[0017] 3) IP replacement: The IP replacement box replaces the 64-bit binary data according to the data content of the corresponding position of the IP replacement box, and then divides it into 32-bit groups of L m*n , R m*n Two matrices, where m=4, n=8, R m*nThe binary blocks of the region will be passed into the encryption round as encryption objects and transformed by the F-round function.
[0018] The encryption F-round function transformation method in step (3) comprises the following steps:
[0019] 1) E box expansion: R 4*8 The binary matrix is expanded from 32-bit to 48-bit in R 4*8 The left and right ends are each expanded and filled with a column of new data. The first column added is respectively extracted from the binary value data of the eight positions [32, 4, 8, 12, 16, 20, 24, 28] of the previous matrix block as the added column, and the last column added is respectively extracted from the binary values of the eight positions [5, 9, 13, 17, 21, 25, 29, 1] of the next matrix block as the added column. The front and back matrix data will be in the form of first-bit crossover, thereby expanding the 32-bit R matrix to 48-bit, and performing an XOR operation on the expanded R matrix and the Ki key of step S32;
[0020] 2) Generate subkey Ki: Generate a 48-bit subkey K from a 64-bit seed key i , use a permutation selector to make the 64-bit seed key lose the parity bit data in eight positions [8,16,24,32,40,48,56,64], then divide the 56-bit seed key into key 1 and key 2, then shift key 1 and key 2 left by 1 or 2 bits, merge key 1 and key 2, and then use the permutation selector to lose the binary value data in eight positions [9,18,22,25,35,38,43,54], and rearrange the remaining 48-bit key in shuffle order to form subkey K i ;
[0021] 3) K i XOR operation: subkey K i Perform an XOR operation with the plaintext R to be encrypted to obtain a new R matrix, that is, load the result of the XOR operation into R;
[0022] 4) S-box compression: Divide the data of the R matrix into eight 6-bit groups, combine the first binary number and the last binary number of each group and convert them into decimal, and convert the remaining four bits in the middle into decimal. Correspond it to the S-box static table to get its corresponding decimal value and convert it into four-bit binary, so as to compress each group of 6-bit to 4-bit, and compress R from 48-bit to 32-bit;
[0023] 5) P-box replacement: Use the 32-bit IP replacement box to replace the positions of each binary number in the R matrix according to the positions in the IP replacement box;
[0024] 6) Exchange R and L matrices: Through an intermediate container, put the data in the R matrix into the L matrix, and put the data in the L matrix into the R matrix, and the L matrix becomes the R matrix. The above encryption process is completed after the loop is executed sixteen times, that is, i=1, 2, 3,..., 16, and the F round function ends, where: Round transformation formula:
[0025] 。
[0026] The beneficial effects of the present invention are as follows: the present invention fully considers the size of the encrypted image data and the characteristics of the image color distribution, first performs an XOR operation on the image to be encrypted and the standard template image, and then performs triple DES encryption. The two encryptions can fully guarantee the security of image transmission, and have a high encryption rate, which can be applied to the encrypted transmission of large amounts of data. In the triple DES encryption process, each encryption unit performs serial encryption, that is, by setting an initialization vector IV to perform an XOR operation with each plaintext group, and then performing an XOR operation on the encrypted ciphertext and the next plaintext group to be encrypted, so that the plaintext groups are connected in series, further improving the security of encryption. The urine test strip image encryption method draws on a variety of algorithms, has the characteristics of high anti-attack and fast information encryption speed, and can effectively guarantee the security and efficiency of urine test strip images during transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 This is a diagram of the implementation steps of the urine test paper image encryption algorithm based on DES in an embodiment of the present invention;
[0028] Figure 2 This is a schematic diagram of serial connection of blocks to be encrypted in an embodiment of the present invention;
[0029] Figure 3 This is a schematic diagram of an IP replacement box according to an embodiment of the present invention;
[0030] Figure 4 This is a diagram of the implementation steps of subkey generation according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0032] Example:
[0033] like Figure 1 As shown, a urine test paper image encryption method based on DES specifically includes the following steps:
[0034] 1) Encrypt the urine test strip image once. Obtain the urine test strip image to be encrypted with a pixel size of 400*2660 from the folder and convert it into binary data. Perform XOR operation bit by bit on the urine image to be encrypted and the binary data file of the urine test strip standard template key image of the same size. Through the XOR operation, hide the details of the image to be encrypted in the new image and obtain the triple DES cyclic encrypted image sample.
[0035] 2) Preparation of triple DES encrypted data: Perform triple DES encryption on the binary data file of the image sample generated after XOR encryption described in step 1), and divide the binary data of the image sample into 64-bit units to be encrypted. If a group of units is less than 64 bits, fill the data to 64 bits, i.e. 8 bytes, using the PKCS5Padding standard. The padding data is the length of the padding bytes. First, calculate the unit length Len. The length after padding using this method is Len+(8-(len%8)), and the padded data length is 8-(Len%8).
[0036] Now there are 3 bytes, the block size is 8 bytes, and 5 bytes need to be filled, that is, filled with 05.
[0037] Original data: 66 6F 72
[0038] Data after padding: 66 6F 72 05 05 05 05 05
[0039] like Figure 2 As shown in the figure, in order to allow all unit blocks to be encrypted in order, an initialization vector IV is set to perform an XOR operation with each plaintext group, and then the encrypted ciphertext is XORed with the next plaintext group to be encrypted, which can create a series connection between the plaintext groups and improve the security of encryption. After the above steps, the grouping work is completed and IP replacement is ready. This step uses Figure 3 The IP substitution box shown replaces the 64-bit binary data according to the IP substitution box and the corresponding position, and then divides it into 32-bit groups of L m*n , R m*n Two matrices, where m=4 and n=8, the binary blocks in the R region will be passed into the encryption round as encryption objects and transformed by the F round function. The 64-bit encryption unit is divided into 32-bit L m*n , R m*n Two groups of blocks to be encrypted, L m*n , R m*n The two blocks to be encrypted are ready to be transformed by the F-round function.
[0040] 3) F round function transformation, the 32-bit R described in step 2)4*8 The block to be encrypted is used as an E-box expansion, that is, in R 4*8 The left and right ends are expanded to fill a new column of data. The first column added is the binary value data of the eight positions [32, 4, 8, 12, 16, 20, 24, 28] of the previous matrix block as the added column, and the last column added is the binary value of the eight positions [5, 9, 13, 17, 21, 25, 29, 1] of the next matrix block as the added column, so that R 4*8 The matrix is expanded to 48-bit, waiting for the subkey K i After generation, perform XOR operation with it.
[0041] like Figure 4 Generate subkey K as shown i Step 1: Use a 64-bit initial key to generate a 48-bit subkey K i, Use the key permutation selector to make the 64-bit seed key lose the parity bit data in eight positions [8,16,24,32,40,48,56,64], then divide the 56-bit seed key into key C0 and key D0, then shift key C0 and key D0 left by 1 or 2 bits as a whole, then merge key C0 and key D0, use the permutation selector to lose the binary value data in eight positions [9,18,22,25,35,38,43,54], and rearrange the remaining 48-bit key in shuffled order to form subkey K i Then the 48-bit subkey Ki is combined with R 6*8 The matrix is XORed and the result of the XOR operation is loaded into R 6*8 .
[0042] S box compression, that is, 48-bit R 6*8 Compress back to 32-bit, first convert R 6*8 The data of the matrix is divided into eight groups of 6 bits. The first binary number and the last binary number of each group are combined and converted into decimal. The remaining four bits in the middle are also converted into decimal. The corresponding decimal value is converted into four-bit binary by mapping it to the static table of the S box, thereby compressing each group of 6 bits to 4 bits, and compressing R from 48 bits to 32 bits.
[0043] P-box substitution uses a 32-bit IP substitution box to swap the positions of binary values in the R matrix according to the positions in the IP substitution box.
[0044] The R and L matrices are swapped, and the data in the R matrix is put into the L matrix, and the data in the L matrix is put into the R matrix through an intermediate container, and the L matrix becomes the R matrix in the above encryption process.
[0045] The F-round function transformation step needs to be executed 16 times in a loop, that is, i=1, 2, 3, ..., 16, and the F-round function transformation ends.
[0046] 4) Triple DES cycle, looping step 2) preparation of encrypted data sample, step 3) F-round function transformation three times, outputting the final encrypted binary data file, and obtaining the DES-based urine test paper encrypted image after conversion.
Claims
1. A urine test strip image encryption method based on DES, Its characteristics are: The steps include: (1) Encrypt the image to be encrypted once: read the image to be encrypted and the key image, traverse the RGB values of the pixels of the image to be encrypted and the key image one by one, and convert them into binary files. Use the key image and the image to be encrypted to perform an XOR operation to obtain the binary data of the hidden information image; (2) Encrypt the image using the 3DES algorithm: Obtain the binary data of the hidden information image in step (1), encrypt it block by block, divide the binary file into 64-bit binary blocks, perform IP substitution on the obtained binary blocks, and obtain 32-bit L and R substitution binary blocks respectively as the plaintext to be encrypted; (3) Encryption F-round function transformation: The plaintext to be encrypted is input into the encryption F-round function transformation, and the expansion, XOR transformation, compression, and substitution operations are performed in sequence. After the L and R regions are swapped, the F-round function is cycled 16 times and the F-round function is encrypted. (4) Triple DES cycle: Repeat steps (2) to (3) to increase the number of encryption times and achieve triple security encryption. in: The method for encrypting the image to be encrypted in step (1) comprises the following steps: 1) Obtain the digital image to be encrypted, the key digital image, and the width and height of the digital image, and convert the digital image into a binary file; 2) One-time encryption: Compare the sizes of the binary files generated by the digital image to be encrypted and the key digital image. If the sizes are different, return to the previous logic layer. If they are the same, perform an XOR operation to complete the one-time encryption and output the binary file that is initially encrypted by the XOR operation of the key image; binary XOR operation formula: ; The method for encrypting an image using the 3DES algorithm in step (2) comprises the following steps: 1) Block division: Obtain the binary file that has completed the initial encryption from step (1) and divide it into 64-bit units. The DES algorithm structure limits the plaintext input to 64-bit. It is necessary to fill the last group in the above step that may not meet the 64-bit bit. Use the PKCS5Padding filling mode. Set the unit data size to len bytes, that is, before encryption, the data byte len is modulo 8, and the remainder is m. If m>0, then fill in 8-m bytes, and the byte value is 8-m, that is, fill in as many bytes as the difference, and the byte value is the number of supplemented bytes. If m is 0, fill in 8 bytes of 8; when decrypting, take the last byte, and the value is m, then delete m bytes from the end of the data, and the remaining data is the original text before encryption. After the grouping is completed, start encryption in 64-bit groups; 2) Group concatenation: Before entering the F-round function, set an initialization vector IV to perform an XOR operation with each plaintext group, and then perform an XOR operation on the encrypted ciphertext and the next plaintext group to be encrypted, so that the plaintext groups are connected in series, improving the security of encryption, and preparing to transfer the group data to the IP replacement box; 3) IP replacement: The IP replacement box replaces the 64-bit binary data according to the data content of the corresponding position of the IP replacement box, and then divides it into 32-bit groups of L m*n , R m*n Two matrices, where m=4, n=8, R m*n The binary blocks of the region will be passed into the encryption round as encryption objects and transformed by the F-round function.
2. The urine test paper image encryption method based on DES according to claim 1, Its characteristics are: The encryption F-round function transformation method in step (3) comprises the following steps: 1) E box expansion: R 4*8 The binary matrix is expanded from 32-bit to 48-bit in R 4*8 The left and right ends are each expanded with a new column of data. The first column added is the binary value data of the eight positions [32, 4, 8, 12, 16, 20, 24, 28] of the previous matrix block as the added column, and the last column added is the binary value of the eight positions [5, 9, 13, 17, 21, 25, 29, 1] of the next matrix block as the added column. The front and back matrix data will be in the form of first-bit crossover, so that the 32-bit R matrix is expanded to 48-bit, and the expanded R matrix is XORed with the subkey Ki; 2) Generate subkey Ki: Generate a 48-bit subkey Ki from a 64-bit seed key. Use a permutation selector to make the 64-bit seed key lose the parity bit data in eight positions [8,16,24,32,40,48,56,64]. Then divide the 56-bit seed key into key 1 and key 2. Then shift key 1 and key 2 left by 1 or 2 bits as a whole. Then merge key 1 and key 2. Then use a permutation selector to lose the binary value data in eight positions [9,18,22,25,35,38,43,54]. Then shuffle the order of the remaining 48-bit key and rearrange it to form subkey Ki. 3) Ki XOR operation: The subkey Ki is XORed with the plaintext R to be encrypted to obtain a new R matrix, that is, the result of the XOR operation is loaded into R; 4) S-box compression: Divide the data of the R matrix into eight 6-bit groups, combine the first binary number and the last binary number of each group and convert them into decimal, and convert the remaining four bits in the middle into decimal. Correspond it to the S-box static table to get its corresponding decimal value and convert it into four-bit binary, so as to compress each group of 6-bit to 4-bit, and compress R from 48-bit to 32-bit; 5) P-box replacement: Use the 32-bit IP replacement box to replace the positions of each binary number in the R matrix according to the positions in the IP replacement box; 6) Exchange R and L matrices: Through an intermediate container, put the data in the R matrix into the L matrix, and put the data in the L matrix into the R matrix, and the L matrix becomes the R matrix. The above encryption process is completed after the loop is executed sixteen times, that is, i=1, 2, 3,..., 16, and the F round function ends, where: Round transformation formula: 。
