CN106530206B - Image encryption and decryption method and device based on optical encryption and decryption technology - Google Patents

Image encryption and decryption method and device based on optical encryption and decryption technology Download PDF

Info

Publication number
CN106530206B
CN106530206B CN201611036562.7A CN201611036562A CN106530206B CN 106530206 B CN106530206 B CN 106530206B CN 201611036562 A CN201611036562 A CN 201611036562A CN 106530206 B CN106530206 B CN 106530206B
Authority
CN
China
Prior art keywords
decimal
sequence
binary
code
codes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611036562.7A
Other languages
Chinese (zh)
Other versions
CN106530206A (en
Inventor
邹文斌
焦述铭
庄兆永
李霞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen University
Original Assignee
Shenzhen University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen University filed Critical Shenzhen University
Priority to CN201611036562.7A priority Critical patent/CN106530206B/en
Publication of CN106530206A publication Critical patent/CN106530206A/en
Application granted granted Critical
Publication of CN106530206B publication Critical patent/CN106530206B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/0021Image watermarking

Abstract

The invention discloses an image encryption and decryption method and device based on optical encryption and decryption technology, wherein the method comprises the following steps: the method comprises the steps of converting an image to be encrypted into a binary sequence code, converting the binary sequence code into a decimal sequence code according to a preset conversion sequence rule, dividing the decimal sequence code into a plurality of segments according to the sequence from the first bit to the last bit in the decimal sequence code, setting the capacity of each segment in the plurality of segments to be smaller than or equal to the maximum capacity of a single two-dimensional code, converting the segments into two-dimensional codes corresponding to the segments, and optically encrypting the two-dimensional codes to ensure that the encrypted two-dimensional codes are restored into the image to be encrypted through optical decryption, so that the two-dimensional codes are used as carriers of the image, and then optically encrypting the two-dimensional codes, the image restored through optical decryption can be prevented from being interfered by speckle noise, and the decrypted image is clearer and more complete.

Description

Image encryption and decryption method and device based on optical encryption and decryption technology
Technical Field
The invention belongs to the technical field of optical encryption and decryption, and particularly relates to an image encryption and decryption method and device based on an optical encryption and decryption technology.
Background
The information encryption technology can protect the electronic information in the transmission and storage processes and prevent the electronic information from being leaked to illegal users. The optical encryption technology has the advantages of high parallelism, high speed, multiple encryption parameters and the like, and is expected to occupy a place in the future encryption technology field. For an image, common optical encryption techniques include: double Random Phase Encryption (DRPE), Fractional Fourier Transform (FFT) based Double random phase encryption, wavelength multiplexing encryption, and phase truncation based asymmetric encryption, and the like.
However, the optical encryption techniques in the prior art all have a disadvantage: after the optical encryption technology is adopted, the original image decrypted again is seriously interfered by speckle noise, and the definition of the decrypted image is further influenced.
Disclosure of Invention
The invention provides an image encryption and decryption method and device based on an optical encryption and decryption technology, and aims to solve the problem that the definition of a decrypted image is influenced because the image decrypted by the existing optical encryption technology is seriously interfered by speckle noise.
The invention provides an image encryption method based on optical encryption and decryption technology, which comprises the following steps: converting an image to be encrypted into a binary sequence code; converting the binary sequence code into a decimal sequence code according to a preset conversion sequence rule; dividing the decimal sequence code into a plurality of segments according to the sequence from the first digit to the last digit in the decimal sequence code, and setting the capacity of each segment in the plurality of segments to be smaller than or equal to the maximum capacity of a single two-dimensional code; and converting the fragments into two-dimensional codes corresponding to the fragments, and optically encrypting the two-dimensional codes so as to restore the encrypted two-dimensional codes into the images to be encrypted through optical decryption.
The invention provides an image decryption method based on optical encryption and decryption technology, which comprises the following steps: the method comprises the steps of optically decrypting a two-dimensional code to be decrypted to obtain a decrypted two-dimensional code, and converting the decrypted two-dimensional code into a segment containing decimal numbers; arranging the converted segments according to segment serial numbers preset in the decrypted two-dimensional code to generate a decimal sequence code; converting the decimal sequence code into a binary sequence code according to a preset conversion sequence rule; and restoring the converted binary sequence code into an image.
The invention provides an image encryption device based on optical encryption and decryption technology, which comprises: the conversion module is used for converting the image to be encrypted into a binary sequence code; the conversion module is further used for converting the binary sequence code into a decimal sequence code according to a preset conversion sequence rule; the dividing module is used for dividing the decimal sequence code into a plurality of segments according to the sequence from the first digit to the last digit in the decimal sequence code, and setting the capacity of each segment in the plurality of segments to be smaller than or equal to the maximum capacity of a single two-dimensional code; the conversion module is further configured to convert the segment into a two-dimensional code corresponding to the segment, and optically encrypt the two-dimensional code, so that the encrypted two-dimensional code is optically decrypted and restored to the image to be encrypted.
The invention provides an image decryption device based on optical encryption and decryption technology, which comprises: the conversion module is used for optically decrypting the two-dimensional code to be decrypted to obtain a decrypted two-dimensional code and converting the decrypted two-dimensional code into a segment containing decimal numbers; the generating module is used for arranging the converted segments according to segment serial numbers preset in the decrypted two-dimensional code so as to generate a decimal sequence code; the conversion module is used for converting the decimal sequence code into a binary sequence code according to a preset conversion sequence rule; the restoration module is used for restoring the converted binary sequence code into an image.
The image encryption and decryption method and device based on the optical encryption and decryption technology provided by the invention convert the image to be encrypted into binary sequence codes, converting the binary sequence code into a decimal sequence code according to a preset conversion sequence rule, dividing the decimal sequence code into a plurality of segments according to the sequence from the first bit to the last bit in the decimal sequence code, setting the capacity of each of the plurality of segments to be less than or equal to the maximum capacity of a single two-dimensional code, converting the segment into a two-dimensional code corresponding to the segment, and optically encrypting the two-dimensional code, so that the encrypted two-dimensional code is restored into the image to be encrypted through optical decryption, the two-dimensional code is used as a carrier of the image, the two-dimensional code is optically encrypted, the image restored through optical decryption can be prevented from being interfered by speckle noise, and the decrypted image is clearer and more complete.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention.
Fig. 1 is a schematic flow chart of an implementation of an image encryption method based on an optical encryption and decryption technique according to a first embodiment of the present invention;
fig. 2 is a schematic flow chart of an implementation of an image encryption method based on an optical encryption and decryption technique according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of a process of converting an image into a two-dimensional code;
fig. 4 is a schematic flow chart of an implementation of an image decryption method based on an optical encryption and decryption technique according to a third embodiment of the present invention;
FIG. 5 is a schematic diagram of an image decryption method corresponding to the image encryption method of FIG. 3;
fig. 6 is a schematic structural diagram of an image encryption device based on an optical encryption and decryption technique according to a fourth embodiment of the present invention;
fig. 7 is a schematic structural diagram of an image encryption device based on optical encryption and decryption technology according to a fifth embodiment of the present invention;
fig. 8 is a schematic structural diagram of an image decryption apparatus based on optical encryption and decryption technology according to a sixth embodiment of the present invention.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a schematic diagram of a flow chart of an implementation of an image encryption method based on an optical encryption and decryption technique according to a first embodiment of the present invention, which can be applied to an optical encryption and decryption system, and the image encryption method shown in fig. 1 mainly includes the following steps:
and S101, converting the image to be encrypted into a binary sequence code.
The image to be encrypted is a gray image or a color image. In a Computer, an image to be encrypted in any storage Format may be converted into a binary sequence code, and the storage Format of the image to be encrypted may be a Bitmap file (BMP) Format, a Personal Computer Interchange (PCX) Format, a Graphics Interchange Format (GIF) Format, a Joint Photographic Experts Group (JPEG) Format, or other storage formats, which are not described herein.
And S102, converting the binary sequence code into a decimal sequence code according to a preset conversion sequence rule.
S103, dividing the decimal sequence code into a plurality of segments according to the sequence from the first bit to the last bit in the decimal sequence code, and setting the capacity of each segment in the plurality of segments to be smaller than or equal to the maximum capacity of a single two-dimensional code.
Each segment contains a plurality of decimal numbers. The maximum capacity is a fixed parameter, and different kinds of two-dimensional codes have different maximum capacities. For example, the maximum capacity of a single conventional two-dimensional Code is 1167 digits, and the maximum capacity of a single Micro QR Code is 35 digits.
S104, converting the fragment into a two-dimensional code corresponding to the fragment, and optically encrypting the two-dimensional code to restore the encrypted two-dimensional code into the image to be encrypted through optical decryption.
One segment is correspondingly converted into a two-dimensional code. The generated two-dimensional codes all need to be optically encrypted to obtain encrypted two-dimensional codes.
In the embodiment of the invention, an image to be encrypted is converted into a binary sequence code; the binary sequence code is converted into a decimal sequence code according to a preset conversion sequence rule, the decimal sequence code is divided into a plurality of segments according to the sequence from the first bit to the last bit in the decimal sequence code, the capacity of each segment in the plurality of segments is set to be smaller than or equal to the maximum capacity of a single two-dimensional code, the segments are converted into two-dimensional codes corresponding to the segments, and the two-dimensional codes are optically encrypted, so that the encrypted two-dimensional codes are restored into the image to be encrypted through optical decryption, the two-dimensional codes are used as carriers of the image, and the two-dimensional codes are optically encrypted, so that the image restored through the optical decryption can be prevented from being interfered by speckle noise, and the decrypted image is clearer and more complete.
Referring to fig. 2, fig. 2 is a schematic diagram of a flow chart of an implementation of an image encryption method based on an optical encryption and decryption technique according to a second embodiment of the present invention, which can be applied to an optical encryption and decryption system, and the image encryption method based on the optical encryption and decryption technique shown in fig. 2 mainly includes the following steps:
s201, converting the image to be encrypted into a binary sequence code.
The image to be encrypted is a grayscale image. In the computer, the image to be encrypted in any storage format may be converted into a binary sequence code, and the storage format of the image to be encrypted may be a BMP format, a PCX format, a GIF format, a JPEG format, or another storage format, which is not described herein again.
S202, extracting four bits from the binary number which is not converted into the decimal number in the binary sequence code according to a preset sequence.
The preset sequence is the arrangement sequence from the first bit to the last bit in the binary sequence code. For example, the binary sequence code converted from the image in S201 is 10010101111000, the first bit of the binary sequence code is binary code 1 located at the leftmost side of the entire sequence, the last bit of the binary sequence code is binary code 0 located at the rightmost side of the entire sequence, and the four bits extracted from the binary sequence code are 1001.
And S203, determining a mode of converting the binary number into the decimal number according to the numerical values of the four bits.
Optionally, the determination of the manner of converting the binary number into the decimal number through the values of the four bits is specifically as follows:
if the four bits are 1000 or 1001, converting the four bits of 1000 into decimal number 8 or converting the four bits of 1001 into decimal number 9 according to a preset binary decimal conversion rule;
if the four bits are neither 1000 nor 1001, extracting three bits from the binary number which is not converted into the decimal number in the binary sequence code again according to the preset sequence, and converting the three bits into the decimal number according to the binary decimal conversion rule.
The preset binary decimal conversion rule is as follows: binary number 1000 is converted to decimal number 8, binary number 1001 is converted to decimal number 9, binary number 000 is converted to decimal number 0, binary number 001 is converted to decimal number 1, binary number 010 is converted to decimal number 2, binary number 011 is converted to decimal number 3, binary number 100 is converted to decimal number 4, binary number 101 is converted to decimal number 5, binary number 110 is converted to decimal number 6, and binary number 111 is converted to decimal number 7.
And S204, continuously executing the process of extracting four bits until all binary numbers in the binary sequence code are converted into decimal numbers.
Taking binary sequence code 10010101111000 as an example to explain step S202-step S203, firstly, extracting four unconverted bits 1001 from the sequence according to a preset sequence, and directly converting 1001 into decimal number 9; continuously extracting four unconverted bits 0101 according to a preset sequence, wherein the four bits are neither 1000 nor 1001, then extracting three unconverted bits 010 again according to the preset sequence, and converting the 010 into a decimal number 2; then continuing to extract four unconverted bits 1111 from the sequence according to the preset sequence, wherein the four bits are neither 1000 nor 1001, then re-extracting three unconverted bits 111 according to the preset sequence, and converting the three unconverted bits 111 into decimal number 7; then, the four unconverted bits 1000 are extracted from the sequence according to the preset sequence, and the 1000 is directly converted into the decimal number 8.
S205, arranging the obtained decimal numbers according to the sequence of the conversion to obtain the decimal serial code.
The decimal numbers obtained by conversion first are arranged in front of the decimal numbers obtained by conversion in the front-rear order of conversion, and the decimal numbers obtained by conversion later are arranged behind the decimal numbers obtained by conversion in the front-rear order of conversion, for example, as exemplified by the decimal numbers obtained by conversion in the above step S204, the decimal sequence codes obtained by arranging in the front-rear order of conversion are: 9278.
s206, dividing the decimal sequence code into a plurality of segments according to the sequence from the first bit to the last bit in the decimal sequence code, and setting the capacity of each segment in the plurality of segments to be smaller than or equal to the maximum capacity of a single two-dimensional code.
Each segment contains a plurality of decimal numbers. The order of the first to last digits in the decimal sequence code is identical to the order of the first to last digits in the binary sequence code, for example, the decimal sequence code is 9278, the first digit of the decimal sequence code is 9, and the last digit of the decimal sequence code is 8. The capacity of each segment must be smaller than or equal to the maximum capacity of a single two-dimensional code, for example, assuming that the maximum capacity of a single two-dimensional code is 2 digits and the decimal serial code is 9278, the two segments divided are: segment a includes 9 and 2, segment B includes 7 and 8; assuming that the maximum capacity of a single two-dimensional code is 3 numbers, two division modes are provided, the first division mode is as follows: segment a includes 9 and 2, segment B includes 7 and 8; the second division mode is as follows: segment a includes 9, 2 and 7, and segment B includes 8.
S207, converting the fragment into a two-dimensional code corresponding to the fragment, and optically encrypting the two-dimensional code to restore the encrypted two-dimensional code into the image to be encrypted through optical decryption.
S208, according to the arrangement sequence of each decimal number in the decimal sequence code, inserting a preset segment serial number into the two-dimensional code corresponding to each segment, so that the divided segments are restored into the decimal sequence code according to the segment serial numbers during decryption.
One segment is correspondingly converted into a two-dimensional code. The sequence numbers of the fragments are used to indicate the sequence of the fragment arrangement. The segment sequence numbers can be represented in the form of numbers, such as 1, 2, 3 …. N, the smaller the number, the more forward the arrangement, the roman number can be used as the segment sequence number, and the characters with the arrangement sequence can be customized. For example, the decimal sequence code is 9278, segment a includes 9 and 2, segment B includes 7 and 8, the segment number of segment a is 1, the segment number of segment B is 2, segment a is arranged in front, and segment B is arranged behind. The order of the digits in the decimal sequence code generated by the segment during decryption can be ensured to be consistent with the order of the digits in the decimal sequence code during encryption through the segment sequence number.
Fig. 3 is a schematic diagram of a process of converting an image into a two-dimensional code. As shown in fig. 3, the following describes the above steps S201 to S208 by using a practical example, which is specifically as follows:
step 1: converting the image to be encrypted into 001110100010011110110010010001000 binary sequence codes;
step 2, extracting four bits 0011 from the binary number which is not converted into the decimal number in the binary sequence code according to a preset sequence;
and step 3: if the four bits are neither 1000 nor 1001, extracting three bits 001 from the binary number which is not converted into the decimal number in the binary sequence code according to the preset sequence again, and converting the bit into the decimal number 1 according to the decimal conversion rule;
and 4, step 4: continuing to execute the step 1, wherein the extracted four bits are 1101, then executing the step 3, wherein the three re-extracted bits are 110, and converting 110 into decimal number 6;
and 5: continuing to execute the step 1, wherein the four extracted bits are 1000, and directly converting 1000 into decimal numbers 8;
step 6: continuing to execute the step 1, wherein the four extracted bits are 1001, and directly converting 1001 into decimal numbers 9;
converting the binary sequence code of step 1 into a decimal sequence code 1689731108 according to the above process;
assuming that the maximum capacity of the two-dimensional code is 4 digits, dividing the decimal sequence code into three segments, namely segment 1, segment 2 and segment 3, wherein 1689 is included in segment 1, 7311 is included in segment 2, and 08 is included in segment 3, and each segment is smaller than the maximum capacity of a single two-dimensional code;
then, the segment 1 is converted into a two-dimensional code A, the segment 2 is converted into a two-dimensional code B, and the segment 3 is converted into a two-dimensional code C, wherein the numbers 1, 2 and 3 are segment serial numbers.
It should be noted that the above manner of dividing the segments is only an example, and in the case that each of the divided segments is smaller than the maximum capacity of a single two-dimensional code, other dividing manners may be selected.
In the embodiment of the invention, an image to be encrypted is converted into a binary sequence code, four bits are extracted from binary numbers which are not converted into decimal numbers in the binary sequence code according to a preset sequence, the mode of converting the binary numbers into the decimal numbers is determined according to the numerical values of the four bits, the process of extracting the four bits is continuously executed until all the binary numbers in the binary sequence code are converted into the decimal numbers, the obtained decimal numbers are arranged according to the sequence from front to back of the conversion to obtain the decimal sequence code, the decimal sequence code is divided into a plurality of segments according to the sequence from the first bit to the last bit in the decimal sequence code, the capacity of each segment in the plurality of segments is set to be smaller than or equal to the maximum capacity of a single two-dimensional code, the segments are converted into two-dimensional codes corresponding to the segments, and the two-dimensional codes are optically encrypted, the encrypted two-dimensional code is restored into the image to be encrypted through optical decryption, a preset segment serial number is inserted into the two-dimensional code corresponding to each segment according to the arrangement sequence of each decimal number in the decimal sequence code, so that the divided segments are restored into the decimal sequence code according to the segment serial numbers during decryption, the two-dimensional code is used as a carrier of the image, the two-dimensional code is optically encrypted, the image restored through optical decryption can be prevented from being interfered by speckle noise, and the decrypted image is clearer and more complete.
Referring to fig. 4, fig. 4 is a schematic diagram of an implementation flow of an image decryption method based on an optical encryption and decryption technique according to a third embodiment of the present invention, which can be applied to an optical encryption and decryption system, and the image decryption method based on the optical encryption and decryption technique shown in fig. 4 mainly includes the following steps:
s401, the two-dimensional code to be decrypted is optically decrypted to obtain a decrypted two-dimensional code, and the decrypted two-dimensional code is converted into a segment containing decimal numbers.
S402, arranging the converted segments according to the segment serial numbers preset in the decrypted two-dimensional code to generate a decimal sequence code.
S403, converting the decimal sequence code into a binary sequence code according to a preset conversion sequence rule;
and S404, restoring the converted binary sequence code into an image.
The decryption method in steps S401 to S404 corresponds to the image encryption method in the embodiment shown in fig. 1 and fig. 2, and please refer to the description of the embodiment shown in fig. 1 and fig. 2 for related contents, which is not described herein again.
Fig. 5 is a schematic diagram of an image decryption method corresponding to the image encryption method in fig. 3.
In the embodiment of the invention, the two-dimensional code to be decrypted is optically decrypted to obtain the decrypted two-dimensional code, the decrypted two-dimensional code is converted into the segment containing the decimal number, the converted segment is arranged according to the segment serial number preset in the decrypted two-dimensional code to generate the decimal sequence code, the decimal sequence code is converted into the binary sequence code according to the preset conversion sequence rule, and the converted binary sequence code is restored into the image, so that the two-dimensional code is optically decrypted firstly, and the decrypted two-dimensional code is restored into the image, thereby preventing the interference of speckle noise, further ensuring that the decrypted image is clearer and more complete, and simultaneously, the segment serial number can be more accurately restored into the encrypted decimal sequence code.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an image encryption apparatus based on optical encryption and decryption technology according to a fourth embodiment of the present invention, and for convenience of description, only the parts related to the embodiment of the present invention are shown. The image encryption apparatus based on the optical encryption and decryption technology illustrated in fig. 6 may be an execution subject of the image encryption method based on the optical encryption and decryption technology provided in the foregoing embodiments illustrated in fig. 1 and 2. The image encryption device based on the optical encryption and decryption technology illustrated in fig. 6 mainly includes: a conversion module 601 and a division module 602. The above functional modules are described in detail as follows:
a conversion module 601, configured to convert an image to be encrypted into a binary sequence code;
the conversion module 601 is further configured to convert the binary sequence code into a decimal sequence code according to a preset conversion sequence rule;
a dividing module 602, configured to divide the decimal sequence code into multiple segments according to an order from a first digit to a last digit in the decimal sequence code, and set a capacity of each of the multiple segments to be less than or equal to a maximum capacity of a single two-dimensional code;
the conversion module 601 is further configured to convert the segment into a two-dimensional code corresponding to the segment, and optically encrypt the two-dimensional code, so that the encrypted two-dimensional code is optically decrypted and restored to the image to be encrypted.
For details that are not described in the present embodiment, please refer to the description of the embodiment shown in fig. 1, which is not described herein again.
In the embodiment of the present invention, the conversion module 601 converts the image to be encrypted into binary sequence code, and converts the binary sequence code into a decimal sequence code according to a preset conversion sequence rule, the dividing module 602 divides the decimal sequence code into a plurality of segments according to the sequence from the first digit to the last digit in the decimal sequence code, and setting the capacity of each of the plurality of segments to be less than or equal to the maximum capacity of a single two-dimensional code, the conversion module 601 then converts the segment into a two-dimensional code corresponding to the segment, and optically encrypts the two-dimensional code, so that the encrypted two-dimensional code is restored into the image to be encrypted through optical decryption, the two-dimensional code is used as a carrier of the image, the two-dimensional code is optically encrypted, the image restored through optical decryption can be prevented from being interfered by speckle noise, and the decrypted image is clearer and more complete.
It should be noted that, in the above embodiment of the image encryption apparatus based on the optical encryption and decryption technology illustrated in fig. 6, the division of the functional modules is only an example, and in practical applications, the above function distribution may be performed by different functional modules according to needs, such as configuration requirements of corresponding hardware or convenience of implementation of software, that is, the internal structure of the image encryption apparatus based on the optical encryption and decryption technology is divided into different functional modules to perform all or part of the above described functions. In addition, in practical applications, the corresponding functional modules in this embodiment may be implemented by corresponding hardware, or may be implemented by corresponding hardware executing corresponding software. The above description principles can be applied to various embodiments provided in the present specification, and are not described in detail below.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an image encryption apparatus based on optical encryption and decryption technology according to a fifth embodiment of the present invention, and for convenience of description, only the parts related to the embodiment of the present invention are shown. The image encryption apparatus based on the optical encryption and decryption technology illustrated in fig. 7 may be an execution subject of the image encryption method based on the optical encryption and decryption technology provided in the foregoing embodiments illustrated in fig. 1 and 2. The image encryption device based on the optical encryption and decryption technology illustrated in fig. 7 mainly includes: a conversion module 701, a division module 702 and a setting module 703, wherein the conversion module 701 includes: an extraction module 7011, a determination module 7012, an execution module 7013, and an arrangement module 7014; the determining module 7012 includes: a conversion submodule 70121. The above functional modules are described in detail as follows:
a conversion module 701, configured to convert an image to be encrypted into a binary sequence code.
The image to be encrypted is a grayscale image. In the computer, the image to be encrypted in any storage format may be converted into a binary sequence code, and the storage format of the image to be encrypted may be a BMP format, a PCX format, a GIF format, a JPEG format, or another storage format, which is not described herein again.
The conversion module 701 includes: an extraction module 7011, a determination module 7012, an execution module 7013, and an arrangement module 7014; the determining module 7012 includes: a conversion submodule 70121.
An extracting module 7011, configured to extract four bits from the binary number that is not converted into the decimal number in the binary sequence code according to a preset order.
The preset sequence is the arrangement sequence from the first bit to the last bit in the binary sequence code. For example, the binary sequence code converted from the image in S201 is 10010101111000, the first bit of the binary sequence code is binary code 1 located at the leftmost side of the entire sequence, the last bit of the binary sequence code is binary code 0 located at the rightmost side of the entire sequence, and the four bits extracted from the binary sequence code are 1001.
A determining module 7012, configured to determine, according to the four-bit value, a manner of converting the binary number into the decimal number.
Optionally, the determining module 7012 includes: a conversion submodule 70121.
A conversion sub-module 70121, configured to, if the four bits are 1000 or 1001, convert the four bits that are 1000 into decimal number 8 or convert the four bits that are 1001 into decimal number 9 according to a preset binary to decimal rule;
the converting submodule 70121 is further configured to, if the four bits are neither 1000 nor 1001, extract three bits from the binary codes that are not converted into decimal numbers in the binary sequence code again according to the preset order, and convert the three bits into decimal numbers according to the binary to decimal rule.
The preset binary decimal conversion rule is as follows: binary number 1000 is converted to decimal number 8, binary number 1001 is converted to decimal number 9, binary number 000 is converted to decimal number 0, binary number 001 is converted to decimal number 1, binary number 010 is converted to decimal number 2, binary number 011 is converted to decimal number 3, binary number 100 is converted to decimal number 4, binary number 101 is converted to decimal number 5, binary number 110 is converted to decimal number 6, and binary number 111 is converted to decimal number 7.
The executing module 7013 is configured to continue the process of extracting four bits until all binary numbers in the binary sequence code are converted into decimal numbers.
Taking binary sequence code 10010101111000 as an example to explain step S202-step S203, firstly, extracting four unconverted bits 1001 from the sequence according to a preset sequence, and directly converting 1001 into decimal number 9; continuously extracting four unconverted bits 0101 according to a preset sequence, wherein the four bits are neither 1000 nor 1001, then extracting three unconverted bits 010 again according to the preset sequence, and converting the 010 into a decimal number 2; then continuing to extract four unconverted bits 1111 from the sequence according to the preset sequence, wherein the four bits are neither 1000 nor 1001, then re-extracting three unconverted bits 111 according to the preset sequence, and converting the three unconverted bits 111 into decimal number 7; then, the four unconverted bits 1000 are extracted from the sequence according to the preset sequence, and the 1000 is directly converted into the decimal number 8.
And the arranging module 7014 is configured to arrange the obtained decimal numbers according to the front-back order of the conversion to obtain the decimal sequence code.
The decimal numbers obtained by conversion first are arranged in front of the decimal numbers obtained by conversion in the front-rear order of conversion, and the decimal numbers obtained by conversion later are arranged behind the decimal numbers obtained by conversion in the front-rear order of conversion, for example, as exemplified by the decimal numbers obtained by conversion in the above step S204, the decimal sequence codes obtained by arranging in the front-rear order of conversion are: 9278.
a dividing module 702, configured to divide the decimal sequence code into multiple segments according to an order from a first digit to a last digit in the decimal sequence code, and set a capacity of each of the multiple segments to be less than or equal to a maximum capacity of a single two-dimensional code.
Each segment contains a plurality of decimal numbers. The order of the first to last digits in the decimal sequence code is identical to the order of the first to last digits in the binary sequence code, for example, the decimal sequence code is 9278, the first digit of the decimal sequence code is 9, and the last digit of the decimal sequence code is 8. The capacity of each segment must be smaller than or equal to the maximum capacity of a single two-dimensional code, for example, assuming that the maximum capacity of a single two-dimensional code is 2 digits and the decimal serial code is 9278, the two segments divided are: segment a includes 9 and 2, segment B includes 7 and 8; assuming that the maximum capacity of a single two-dimensional code is 3 numbers, two division modes are provided, the first division mode is as follows: segment a includes 9 and 2, segment B includes 7 and 8; the second division mode is as follows: segment a includes 9, 2 and 7, and segment B includes 8.
The conversion module 701 is configured to convert the segment into a two-dimensional code corresponding to the segment, and optically encrypt the two-dimensional code, so that the encrypted two-dimensional code is optically decrypted and restored to the image to be encrypted.
A setting module 703, configured to insert a preset segment sequence number into the two-dimensional code corresponding to each segment according to the arrangement sequence of each decimal number in the decimal sequence code, so that the divided segments are restored to the decimal sequence code according to the segment sequence number when decrypting.
One segment is correspondingly converted into a two-dimensional code. The sequence numbers of the fragments are used to indicate the sequence of the fragment arrangement. The segment sequence numbers can be represented in the form of numbers, such as 1, 2, 3 …. N, the smaller the number, the more forward the arrangement, the roman number can be used as the segment sequence number, and the characters with the arrangement sequence can be customized. For example, the decimal sequence code is 9278, segment a includes 9 and 2, segment B includes 7 and 8, the segment number of segment a is 1, the segment number of segment B is 2, segment a is arranged in front, and segment B is arranged behind. The order of the digits in the decimal sequence code generated by the segment during decryption can be ensured to be consistent with the order of the digits in the decimal sequence code during encryption through the segment sequence number.
For details of the embodiment, please refer to the description of the embodiment shown in fig. 1 and fig. 2, which is not repeated herein.
In the embodiment of the present invention, the conversion module 701 converts an image to be encrypted into a binary sequence code, the extraction module 7011 extracts four bits from a binary code that is not converted into a decimal number in the binary sequence code according to a preset sequence, the determination module 7012 determines a manner of converting the binary code into the decimal number according to the values of the four bits, the execution module 7013 continues to execute a process of extracting the four bits until all binary codes in the binary sequence code are converted into the decimal number, the arrangement module 7014 arranges the obtained decimal numbers according to a front-to-rear sequence of the conversion to obtain the decimal sequence code, the division module 702 divides the decimal sequence code into a plurality of segments according to a sequence from a first digit to a last digit in the decimal sequence code, and sets the capacity of each segment in the plurality of segments to be less than or equal to the maximum capacity of a single two-dimensional code, the conversion module 701 converts the segment into a two-dimensional code corresponding to the segment, and optically encrypts the two-dimensional code, so that the encrypted two-dimensional code is restored to the image to be encrypted through optical decryption, the setting module 703 inserts a preset segment serial number into the two-dimensional code corresponding to each segment according to the arrangement sequence of the decimal numbers in the decimal sequence code, so that the divided segments are restored to the decimal sequence code according to the segment serial numbers during decryption, and thus, the two-dimensional code is used as a carrier of the image, and then the two-dimensional code is optically encrypted, so that the image restored through optical decryption can be prevented from being interfered by speckle noise, and the decrypted image is clearer and more complete.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an image decryption apparatus based on optical encryption and decryption technology according to a sixth embodiment of the present invention, and for convenience of description, only the parts related to the embodiment of the present invention are shown. The image decryption apparatus based on the optical encryption and decryption technology illustrated in fig. 8 may be the subject of the image decryption method based on the optical encryption and decryption technology provided in the foregoing embodiment illustrated in fig. 3. The image decryption apparatus based on the optical encryption and decryption technique illustrated in fig. 8 mainly includes: a conversion module 801, a generation module 802 and a restoration module 803. The above functional modules are described in detail as follows:
the conversion module 801 is configured to optically decrypt the two-dimensional code to be decrypted to obtain a decrypted two-dimensional code, and convert the decrypted two-dimensional code into a segment including decimal numbers;
a generating module 802, configured to arrange the converted segments according to segment sequence numbers preset in the decrypted two-dimensional code to generate a decimal sequence code;
a conversion module 801, configured to convert the decimal sequence code into a binary sequence code according to a preset conversion sequence rule;
and a restoring module 803, configured to restore the converted binary sequence code into an image.
For details of the embodiment, please refer to the description of the embodiment shown in fig. 1, fig. 2 and fig. 3, which will not be described herein again.
It should be noted that the image decryption apparatus based on the optical encryption and decryption technology in the embodiment of the present invention may be located in one terminal or may be located in a different terminal from the image encryption apparatus based on the optical encryption and decryption technology shown in fig. 6 and 7.
In the embodiment of the invention, the conversion module 801 optically decrypts the two-dimensional code to be decrypted to obtain the decrypted two-dimensional code, converts the decrypted two-dimensional code into a segment containing decimal numbers, the generation module 802 arranges the converted segment according to the segment serial number preset in the decrypted two-dimensional code to generate a decimal sequence code, the conversion module 801 converts the decimal sequence code into a binary sequence code according to a preset conversion sequence rule, and the reduction module 803 reduces the converted binary sequence code into an image, so that the two-dimensional code is optically decrypted first, the decrypted two-dimensional code is reduced into the image, the interference of speckle noise can be prevented, the decrypted image is clearer and more complete, and meanwhile, the segment serial number can be more accurately reduced into the encrypted decimal sequence code.
In the embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and in actual implementation, there may be other divisions, for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication link may be an indirect coupling or communication link of some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present invention is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no acts or modules are necessarily required of the invention.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The above is a description of the image encryption and decryption method and apparatus based on optical encryption and decryption technology provided by the present invention, and for those skilled in the art, there may be variations in the specific implementation and application scope according to the idea of the embodiment of the present invention, and in summary, the content of the present specification should not be construed as limiting the present invention.

Claims (6)

1. An image encryption method based on optical encryption and decryption technology, comprising:
converting an image to be encrypted into a binary sequence code;
extracting four bits from binary codes which are not converted into decimal numbers in the binary sequence codes according to a preset sequence, wherein the preset sequence is the arrangement sequence from the first bit to the last bit in the binary sequence codes;
determining a mode of converting the binary number into a decimal number according to the numerical values of the four bits;
continuing to execute the process of extracting four bits until all binary numbers in the binary sequence codes are converted into decimal numbers;
arranging the obtained decimal numbers according to the sequence of conversion to obtain decimal sequence codes;
dividing the decimal sequence code into a plurality of segments according to the sequence from the first digit to the last digit in the decimal sequence code, and setting the capacity of each segment in the plurality of segments to be smaller than or equal to the maximum capacity of a single two-dimensional code;
converting the fragments into two-dimensional codes corresponding to the fragments, and optically encrypting the two-dimensional codes so as to restore the encrypted two-dimensional codes into the images to be encrypted through optical decryption;
wherein the determining the manner of converting the binary number into the decimal number according to the values of the four bits comprises:
if the four bits are 1000 or 1001, converting the four bits of 1000 into decimal number 8 or converting the four bits of 1001 into decimal number 9 according to a preset binary decimal conversion rule;
if the four bits are neither 1000 nor 1001, extracting three bits from the binary number which is not converted into the decimal number in the binary sequence code again according to the preset sequence, and converting the three bits into the decimal number according to the binary decimal conversion rule.
2. The method of claim 1, wherein after converting the segment into the two-dimensional code corresponding to the segment and optically encrypting the two-dimensional code, the method further comprises:
and inserting preset segment serial numbers into the two-dimensional codes corresponding to each segment according to the arrangement sequence of each decimal number in the decimal sequence codes so as to restore the decimal sequence codes to the divided segments according to the segment serial numbers during decryption.
3. An image decryption method based on optical encryption and decryption, the method comprising:
the method comprises the steps of optically decrypting a two-dimensional code to be decrypted to obtain a decrypted two-dimensional code, and converting the decrypted two-dimensional code into a segment containing decimal numbers;
arranging the converted segments according to segment serial numbers preset in the decrypted two-dimensional code to generate a decimal sequence code;
converting the decimal sequence code into a binary sequence code according to a preset conversion sequence rule;
restoring the converted binary sequence code into an image;
wherein the converting the decimal sequence code into a binary sequence code according to a preset conversion sequence rule comprises:
and converting the sequence codes of 1 to 7 in the decimal sequence codes into binary codes with three bits, and converting 8 and 9 in the decimal sequence codes into binary codes with four bits to obtain the binary sequence codes corresponding to the decimal sequence codes.
4. An image encryption apparatus based on optical encryption and decryption, the apparatus comprising:
the conversion module is used for converting the image to be encrypted into a binary sequence code;
the conversion module is further used for converting the binary sequence code into a decimal sequence code according to a preset conversion sequence rule;
the dividing module is used for dividing the decimal sequence code into a plurality of segments according to the sequence from the first bit to the last bit in the decimal sequence code, and setting the capacity of each segment in the plurality of segments to be smaller than or equal to the maximum capacity of a single two-dimensional code;
the conversion module is further configured to convert the segment into a two-dimensional code corresponding to the segment, and optically encrypt the two-dimensional code, so that the encrypted two-dimensional code is optically decrypted and restored into the image to be encrypted;
wherein the conversion module comprises:
the extraction module is used for extracting four bits from binary codes which are not converted into decimal numbers in the binary sequence codes according to a preset sequence, wherein the preset sequence is the arrangement sequence from the first bit to the last bit in the binary sequence codes;
the determining module is used for determining a mode of converting the binary number into the decimal number according to the numerical values of the four bits;
the execution module is used for continuously executing the process of extracting four bits until all binary numbers in the binary sequence codes are converted into decimal numbers;
the arrangement module is used for arranging the obtained decimal numbers according to the sequence of the conversion to obtain the decimal serial codes;
wherein the determining module comprises:
a conversion submodule, configured to, if the four bits are 1000 or 1001, convert the four bits that are 1000 into a decimal number 8 or convert the four bits that are 1001 into a decimal number 9 according to a preset binary decimal conversion rule;
and the conversion sub-module is further configured to extract three bits from the binary number not converted into the decimal number in the binary sequence code according to the preset sequence again if the four bits are neither 1000 nor 1001, and convert the three bits into the decimal number according to the binary decimal conversion rule.
5. The apparatus of claim 4, further comprising:
and the setting module is used for inserting preset segment serial numbers into the two-dimensional codes corresponding to the segments according to the arrangement sequence of the decimal numbers in the decimal sequence codes so as to restore the decimal sequence codes of the divided segments according to the segment serial numbers during decryption.
6. An image decryption apparatus based on optical encryption and decryption, the apparatus comprising:
the conversion module is used for optically decrypting the two-dimensional code to be decrypted to obtain a decrypted two-dimensional code and converting the decrypted two-dimensional code into a segment containing decimal numbers;
the generating module is used for arranging the converted segments according to segment serial numbers preset in the decrypted two-dimensional code so as to generate a decimal sequence code;
the conversion module is used for converting the decimal sequence code into a binary sequence code according to a preset conversion sequence rule;
the restoration module is used for restoring the converted binary sequence code into an image;
the conversion module arranges the converted segments according to segment serial numbers preset in the decrypted two-dimensional code to generate a decimal sequence code, and the process comprises the following steps: and converting the sequence codes of 1 to 7 in the decimal sequence codes into binary codes with three bits, and converting 8 and 9 in the decimal sequence codes into binary codes with four bits to obtain the binary sequence codes corresponding to the decimal sequence codes.
CN201611036562.7A 2016-11-15 2016-11-15 Image encryption and decryption method and device based on optical encryption and decryption technology Active CN106530206B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611036562.7A CN106530206B (en) 2016-11-15 2016-11-15 Image encryption and decryption method and device based on optical encryption and decryption technology

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611036562.7A CN106530206B (en) 2016-11-15 2016-11-15 Image encryption and decryption method and device based on optical encryption and decryption technology

Publications (2)

Publication Number Publication Date
CN106530206A CN106530206A (en) 2017-03-22
CN106530206B true CN106530206B (en) 2020-01-10

Family

ID=58356159

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611036562.7A Active CN106530206B (en) 2016-11-15 2016-11-15 Image encryption and decryption method and device based on optical encryption and decryption technology

Country Status (1)

Country Link
CN (1) CN106530206B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110650350B (en) * 2017-08-18 2022-04-22 北京奇艺世纪科技有限公司 Method and device for displaying coded image and electronic equipment
CN107947919B (en) * 2017-11-14 2020-06-23 上海理工大学 Compressed sensing correlation imaging encryption method for large-information-volume images based on QR (quick response) codes
WO2019095173A1 (en) * 2017-11-15 2019-05-23 深圳大学 Method and device for generating two-dimensional code superimposed with artificial noise information
WO2019205357A1 (en) * 2018-04-26 2019-10-31 上海德必创新科技发展有限公司 Two-dimensional code encryption method, two-dimensional code transmission system and storage medium
CN112529586B (en) * 2020-12-15 2023-07-28 深圳市快付通金融网络科技服务有限公司 Transaction information management method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1818935A (en) * 2006-03-17 2006-08-16 北京紫光捷通科技有限公司 Two-dimensional code construction based on hexadecimal coding
CN101702240A (en) * 2009-11-26 2010-05-05 大连大学 Image encryption method based on DNA sub-sequence operation
CN103093411A (en) * 2013-01-10 2013-05-08 华南师范大学 Encryption-decryption method based on random binary image
CN103414839A (en) * 2013-07-25 2013-11-27 太原科技大学 Graded-and-grouped secret image sharing method
CN103473733A (en) * 2013-09-12 2013-12-25 东北林业大学 Image encryption algorithm based on DNA encoding and chaotic mapping
CN104424498A (en) * 2013-09-10 2015-03-18 王越 Method and device for transforming two-dimensional codes at high speed

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1818935A (en) * 2006-03-17 2006-08-16 北京紫光捷通科技有限公司 Two-dimensional code construction based on hexadecimal coding
CN101702240A (en) * 2009-11-26 2010-05-05 大连大学 Image encryption method based on DNA sub-sequence operation
CN103093411A (en) * 2013-01-10 2013-05-08 华南师范大学 Encryption-decryption method based on random binary image
CN103414839A (en) * 2013-07-25 2013-11-27 太原科技大学 Graded-and-grouped secret image sharing method
CN104424498A (en) * 2013-09-10 2015-03-18 王越 Method and device for transforming two-dimensional codes at high speed
CN103473733A (en) * 2013-09-12 2013-12-25 东北林业大学 Image encryption algorithm based on DNA encoding and chaotic mapping

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
WAVELET PACKETS-BASED ROBUST BLIND DIGITAL WATERMARK SCHEME;CONG JIN等;《Proceedings of the 2008 International Conference on Wavelet Analysis and Pattern Recognition》;20080831;第724-728页 *
基于Zxing的彩色QR码生成与识别方法;陈元枝;《桂林电子科技大学学报》;20160831;第36卷(第4期);第333-337页 *
基于计算鬼成像的光学加密和数字水印方法研究;梁文强;《中国优秀硕士学位论文全文数据库 基础科学辑》;20160615;第2016年卷(第05期);第A005-36页的摘要、第2.2节和第3.1.2节 *

Also Published As

Publication number Publication date
CN106530206A (en) 2017-03-22

Similar Documents

Publication Publication Date Title
CN106530206B (en) Image encryption and decryption method and device based on optical encryption and decryption technology
US9736142B2 (en) Tokenization using multiple reversible transformations
US20120269340A1 (en) Hierarchical encryption/decryption device and method thereof
CN105468990A (en) Sensitive information management control method and apparatus
CN105893871B (en) A kind of data security protection method and device based on data segmentation
CN103345609A (en) Method and device for text encryption and decryption
CN102224704A (en) Content decoding apparatus, content decoding method and integrated circuit
CN101996298A (en) Encrypting method and decrypting method corresponding to same
CN111191255B (en) Information encryption processing method, server, terminal, device and storage medium
US20130114806A1 (en) Method for encrypting a message through the computation of mathematical functions comprising modular multiplications
CN107534549B (en) Readable storage medium, method and system for encrypting data stream block
US8462948B2 (en) System and method for protecting data of mobile phone
CN112199699A (en) Character string encryption and decryption method and device, storage medium and processor
US11354427B2 (en) Encrypting/decrypting method for multi-digit number and encrypting/decrypting server
CN111798236B (en) Transaction data encryption and decryption methods, devices and equipment
CN112182512A (en) Information processing method, device and storage medium
CN106228503B (en) The digital watermark embedding and extracting method of satellite remote-sensing image SHP dot files
CN110611568B (en) Dynamic encryption and decryption method, device and equipment based on multiple encryption and decryption algorithms
CN111368322A (en) File decryption method and device, electronic equipment and storage medium
CN112236974A (en) Decryption device, encryption device, and encryption system
CN115941304A (en) Data encryption method and device, terminal equipment and computer readable storage medium
CN111368316B (en) File encryption and decryption method and device
CN112100638B (en) Image data processing method, device and equipment based on hardware security isolation area
CN105719223B (en) Batch image encryption method, decryption method and system
CN115834163B (en) Method, device, equipment and storage medium for generating secret key of encrypted data

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant