CN112399027A - Picture encryption and decryption method and device, storage medium and electronic equipment - Google Patents

Picture encryption and decryption method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN112399027A
CN112399027A CN201910750377.1A CN201910750377A CN112399027A CN 112399027 A CN112399027 A CN 112399027A CN 201910750377 A CN201910750377 A CN 201910750377A CN 112399027 A CN112399027 A CN 112399027A
Authority
CN
China
Prior art keywords
picture
encrypted
encryption
character string
binary information
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.)
Granted
Application number
CN201910750377.1A
Other languages
Chinese (zh)
Other versions
CN112399027B (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.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
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 Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN201910750377.1A priority Critical patent/CN112399027B/en
Publication of CN112399027A publication Critical patent/CN112399027A/en
Application granted granted Critical
Publication of CN112399027B publication Critical patent/CN112399027B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/44Secrecy systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords

Abstract

The disclosure provides a picture encryption and decryption method and device, electronic equipment and a storage medium, and relates to the technical field of picture encryption. The picture encryption method comprises the following steps: converting the color information of each pixel of the picture to be encrypted into corresponding first binary information; acquiring a password and operating the password by using an encryption function to obtain an encrypted character string; the bit number of the encrypted character string is the same as the bit number of each piece of first binary information; and encrypting each first binary information by using the encryption character string to obtain an encrypted picture. The method and the device can enhance the security of picture encryption and well reduce the distortion degree of the picture.

Description

Picture encryption and decryption method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of image encryption technologies, and in particular, to an image encryption and decryption method and apparatus, an electronic device, and a computer-readable storage medium.
Background
Pictures are receiving increasing attention as an important means of information storage and communication. For some pictures that involve privacy or confidentiality, people often adopt an encryption mode to protect the security of the pictures.
The current picture encryption method mainly reads the binary stream of the picture, creates a hidden path or file based on the password, and writes the binary stream of the picture into the hidden path or file. However, the encryption mode can easily acquire the original picture by scanning the hard disk, and is easy to crack.
Therefore, it is desirable to provide a picture encryption and decryption method with high security, so as to achieve more effective protection for user privacy and confidential information.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The embodiment of the disclosure provides a picture encryption and decryption method, a picture encryption and decryption device, an electronic device and a computer readable storage medium, so that the problem that an encrypted picture is easy to crack can be solved, and the distortion of the picture can be reduced.
According to a first aspect of the present disclosure, there is provided a picture encryption method, including:
converting the color information of each pixel of the picture to be encrypted into corresponding first binary information;
acquiring a password and operating the password by using an encryption function to obtain an encrypted character string; the bit number of the encrypted character string is the same as the bit number of each piece of first binary information;
and encrypting each first binary information by using the encryption character string to obtain an encrypted picture.
In an exemplary embodiment of the present disclosure, the method further comprises:
converting the size information of the picture to be encrypted into corresponding second binary information;
and encrypting the second binary information by using the encryption character string.
In an exemplary embodiment of the present disclosure, the obtaining a password and operating on the password by using an encryption function to obtain an encrypted string includes:
acquiring the position of each character in the password in a coding table and obtaining a first output value according to the acquired position;
calculating the first output value by using a prime number distribution rule to obtain a plurality of second output values; the number of the second output values is the same as the number of the bits of the encrypted character string;
obtaining corresponding prime numbers according to the second output values; each prime number is sequentially positioned between two adjacent second output values;
and carrying out remainder operation on the digits of the first binary information by utilizing each prime number to obtain each third output value, and assigning values to each character of the encrypted character string according to each third output value.
In an exemplary embodiment of the disclosure, the obtaining a position of each character in the password in a coding table and obtaining a first output value according to the obtained position includes:
and calculating the sum of the positions of each character of the password in a coding table, calculating an average value, and rounding up the average value to obtain a first output value.
In an exemplary embodiment of the disclosure, the calculating the first output value by using a prime number distribution rule to obtain a plurality of second output values includes:
adding an integer to the first output value, squaring the sum, and assigning the result to a plurality of second output values; and the integers are all integers in a front closing and rear opening interval from 0 to the bit number of the encrypted character string in sequence.
In an exemplary embodiment of the disclosure, the performing a remainder operation on the digits of the first binary information by using each of the prime numbers to obtain each of third output values, and assigning a value to each character of the encrypted character string according to each of the third output values includes:
taking a character string of a corresponding system taking the digit number of the encrypted character string as a base number as an assignment character string;
using each third output value as a position pointer to obtain characters at corresponding positions in the assignment character string;
assigning a value to each character in the encrypted string using the character obtained from the assigned string.
In an exemplary embodiment of the disclosure, the encrypting each first binary information by using the encryption string to obtain an encrypted picture includes:
and multiplying each first binary information by using the encryption character string to obtain an encrypted picture.
According to a second aspect of the present disclosure, there is provided a picture decryption method for decrypting a picture encrypted by the above encryption method, including:
acquiring each encrypted first binary information and the password;
calculating the password by using a decryption function to obtain a decryption character string; wherein the decryption function and the encryption function are the same function;
and decrypting each first binary information by using the decryption character string to obtain a decrypted picture.
According to a third aspect of the present disclosure, there is provided a picture encryption apparatus comprising:
the information reading module is used for acquiring a picture to be encrypted and a password;
the type conversion module is used for converting the color information of each pixel of the picture to be encrypted into corresponding first binary information;
the function operation module is used for acquiring an encryption character string by using the encryption function according to the password;
and the picture encryption module is used for carrying out encryption operation on each first binary information by using the encryption character string.
According to a fourth aspect of the present disclosure, there is provided a picture decryption apparatus for decrypting a picture encrypted by using the above picture encryption apparatus, comprising:
the information reading module is used for acquiring each encrypted first binary information and the password corresponding to the picture to be decrypted;
the function operation module is used for acquiring a decryption character string by using a decryption function according to the password;
the picture decryption module is used for decrypting each encrypted first binary information by using the decryption character string;
and the type conversion module is used for reading the first binary information obtained by decryption in a picture form.
According to a fifth aspect of the present disclosure, there is provided an electronic device comprising:
a processor;
a memory for storing executable instructions of the processor; wherein the processor is configured to perform any of the methods described above via execution of the executable instructions.
According to a sixth aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any one of the above.
Exemplary embodiments of the present disclosure may have some or all of the following benefits:
in the picture encryption method provided by the disclosed example embodiment, the color information of each pixel of the picture to be encrypted is converted into corresponding first binary information, the obtained password is calculated and converted into an encryption character string with the same number of bits as the first binary information through an encryption function, and the obtained encryption character string is used for encrypting the first binary information. On one hand, the encryption character string carries out encryption operation on the picture information of the picture to be encrypted, compared with the process of encrypting the storage path of the picture, the security of the picture to be encrypted is higher, and the privacy and confidential information of a user can be better protected. On the other hand, the encryption method can encrypt the first binary information with any digit, and the higher the digit of the first binary information is, the lower the distortion degree of the picture is, so that the distortion degree of the picture can be reduced. In the case of computer-based displays, 100% fidelity to the picture can be achieved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty.
Fig. 1 is a schematic diagram illustrating an exemplary system architecture of a picture encryption and decryption method and apparatus to which the embodiments of the present disclosure may be applied;
FIG. 2 illustrates a schematic structural diagram of a computer system suitable for use with the electronic device used to implement embodiments of the present disclosure;
fig. 3 schematically shows a flow chart of a procedure of a picture encryption method according to one embodiment of the present disclosure;
fig. 4 schematically shows a flowchart of a process of acquiring the encryption string in a picture encryption method according to an embodiment of the present disclosure;
fig. 5 schematically shows a flow chart of a procedure of a picture decryption method according to an embodiment of the present disclosure;
FIG. 6 is a schematic diagram illustrating a picture encryption method in an application scenario according to an embodiment of the present disclosure;
fig. 7 schematically illustrates a schematic diagram of obtaining a 24-bit long string strArray in a picture encryption method of an application scenario according to an embodiment of the present disclosure;
FIG. 8 is a schematic diagram illustrating an encryption process for an application scenario according to an embodiment of the present disclosure;
fig. 9 schematically shows a schematic diagram of a picture decryption method in an application scenario of an embodiment of the present disclosure;
FIG. 10 is a diagram schematically illustrating a decryption process of an application scenario of an embodiment of the present disclosure;
fig. 11 schematically shows a block diagram of a picture encryption apparatus according to an embodiment of the present disclosure;
fig. 12 schematically shows a block diagram of a picture decryption apparatus according to an embodiment of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and the like. In other instances, well-known technical solutions have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repetitive description will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
Fig. 1 is a schematic diagram illustrating a system architecture of an exemplary application environment to which a picture encryption and decryption method and apparatus according to an embodiment of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include one or more of terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few. The terminal devices 101, 102, 103 may be various electronic devices having a display screen, including but not limited to desktop computers, portable computers, smart phones, tablet computers, and the like. It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation. For example, server 105 may be a server cluster comprised of multiple servers, or the like.
The image encryption and decryption method provided by the embodiment of the present disclosure may be executed by the terminal devices 101, 102, and 103, and correspondingly, the image encryption and decryption apparatus may also be disposed in the terminal devices 101, 102, and 103. The image encryption and decryption method provided by the embodiment of the present disclosure may also be executed by the terminal devices 101, 102, and 103 and the server 105, and accordingly, the image encryption and decryption apparatus may be disposed in the terminal devices 101, 102, and 103 and the server 105. In addition, the image encryption and decryption method provided by the embodiment of the present disclosure may also be executed by the server 105, and accordingly, the image encryption and decryption apparatus may be disposed in the server 105, which is not particularly limited in this exemplary embodiment.
FIG. 2 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present disclosure.
It should be noted that the computer system 200 of the electronic device shown in fig. 2 is only an example, and should not bring any limitation to the functions and the scope of the application of the embodiments of the present disclosure.
As shown in fig. 2, the computer system 200 includes a Central Processing Unit (CPU)201 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)202 or a program loaded from a storage section 208 into a Random Access Memory (RAM) 203. In the RAM 203, various programs and data necessary for system operation are also stored. The CPU 201, ROM 202, and RAM 203 are connected to each other via a bus 204. An input/output (I/O) interface 205 is also connected to bus 204.
The following components are connected to the I/O interface 205: an input portion 206 including a keyboard, a mouse, and the like; an output section 207 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 208 including a hard disk and the like; and a communication section 209 including a network interface card such as a LAN card, a modem, or the like. The communication section 209 performs communication processing via a network such as the internet. A drive 210 is also connected to the I/O interface 205 as needed. A removable medium 211 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 210 as necessary, so that a computer program read out therefrom is mounted into the storage section 208 as necessary.
The technical solution of the embodiment of the present disclosure is explained in detail below:
the present exemplary embodiment first provides a picture encryption method, which may be applied to one or more of the terminal devices 101, 102, and 103, may also be applied to the server 105, and may also be applied to one or more of the terminal devices 101, 102, and 103 and the server 105 at the same time, and specifically includes the following steps:
s310, converting color information of each pixel of a picture to be encrypted into corresponding first binary information;
s320, acquiring a password and calculating the password by using an encryption function to obtain an encrypted character string; the bit number of the encrypted character string is the same as the bit number of each piece of first binary information;
and S330, encrypting each first binary information by using the encryption character string to obtain an encrypted picture.
In the image encryption method provided by the disclosed example embodiment, on one hand, the encryption character string performs encryption operation on the image information of the image to be encrypted, compared with the encryption of the storage path of the image, the security of the image to be encrypted is higher, and the privacy and the confidential information of the user can be better protected. On the other hand, the encryption method can encrypt the first binary information with any digit, and the higher the digit of the first binary information is, the lower the distortion degree of the picture is, so that the distortion degree of the picture can be reduced. In the case of computer-based displays, 100% fidelity to the picture can be achieved.
Next, in another embodiment, the above steps are explained in more detail.
In step S310, the color information of each pixel of the picture to be encrypted is converted into corresponding first binary information.
In the present exemplary embodiment, the picture to be encrypted refers to a picture that needs to be stored in an encrypted manner due to user privacy or confidentiality. The picture to be encrypted may be input or specified by the user, or may be automatically classified as the object to be encrypted by the system according to a specific rule, and in addition, the picture to be encrypted may be determined by using other feasible manners, which is not specifically defined in the present exemplary embodiment.
In this example embodiment, the picture to be encrypted may be located in a local storage of the mobile device, may also be located in the cloud server, and may also be used for a picture in a communication transmission process.
In the present exemplary embodiment, the pixel is the smallest unit constituting the picture to be encrypted, and is composed of small squares of the picture, each of which has a definite position and assigned color value, and the color and position of the small squares determine how the picture appears. Wherein, the color value of each pixel can be expressed by using an RGB color mode. The color pattern obtains various colors by the variation of three color channels of red, green and blue and the superposition of the three color channels with each other. The RGB mode can not only ensure rich color information of the picture, but also ensure faster operation speed.
In this exemplary embodiment, the first binary information is a binary representation corresponding to a color value of each pixel of the picture to be encrypted. For example, in the above RGB using 24-bit encoding for each pixel, the first binary information uses three 8-bit unsigned integers (0 to 255) to represent the intensities of red, green, and blue. For example, (0,0,0) indicates black, (255 ) indicates white, (255,0,0) indicates red, (0, 255,0) indicates green, (0,0,255) indicates blue, and (255, 0) indicates yellow. The number of the first binary digits can also be 16 bits; it can also be 32 bits, and the additional 8 bits are used to store the graphics data of the overlapped layers.
In step S320, a password is obtained and an encryption function is used to operate on the password to obtain an encrypted string; the number of bits of the encrypted character string is the same as the number of bits of each piece of the first binary information. For example, referring to fig. 4, in the present exemplary embodiment, the encrypted character string may be obtained through the following steps S410 to S430.
In step S410, the position of each character in the password in the coding table is obtained and a first output value is obtained according to the obtained position.
In the present exemplary embodiment, the password is a character string. The character string can be any character string input by a user, can be randomly generated by a computer and distributed to the user, and can also be generated by the user and the computer together. This exemplary embodiment is not particularly limited thereto.
In this exemplary embodiment, the password may be a pure number, may also be a special character such as a pure letter or a wildcard, and may also be a combination of one or more of the letters, numbers, and special characters.
In the present exemplary embodiment, the number of digits of the password may be any integer. For example, the number of bits of the password may be 6 bits, 8 bits, or more than 10 bits, depending on the degree of security requirement, which is not limited.
In the present exemplary embodiment, the code table is a table formed by encoding letters, numbers or other special letters in a computer. For example, the code table may be a unicode (universal code) code table, which sets a uniform and unique binary code for each character in each language, and can meet the requirements of text conversion and processing across countries, nationalities, languages and platforms. Besides, the encoding table can also be an ASCII encoding table or other encoding tables. This example embodiment is not particularly limited in this regard.
In the present exemplary embodiment, the first output value may be obtained by the following process: finding out the corresponding position of each character in the password in the coding table, calculating the position sum of the characters, calculating the average value of the position sum and rounding up to obtain the first output value, or in another case, rounding down the average value to obtain the first output value.
In another specific example of this example embodiment, the first output value may be obtained by performing an iterative operation on the positions of the characters in the encoding table and averaging, and rounding the average up or down.
Besides, the first output value can be obtained by other operations according to the position of each character in the password in the coding table. This is not particularly required by the present exemplary embodiment.
In step S420, a plurality of second output values are obtained by calculating the first output value according to a prime number distribution rule; and the number of the second output values is the same as the number of the bits of the encrypted character string.
A prime number is a natural number that has no other factor than 1 and itself and is greater than 1. In this exemplary embodiment, the prime number distribution rule refers to a distribution rule of positions of the prime numbers in a natural number. The prime number distribution rule includes but is not limited to the following two types:
if n is>2, then n2And (n +1)2There is at least one prime number in between;
if n >2, there is at least one prime number between n and 2 n.
In the present exemplary embodiment, the number of the second output values is determined by the number of bits of the encrypted character string, that is, the number of bits of the first binary information, and in the present exemplary embodiment, the first binary information may be 24 bits or 32 bits, or may be any other positive integer bits.
In the following description, the number of bits of the first binary information, that is, the number of bits of the encrypted character string and the number of the second output value are denoted by a letter t. The first output value is denoted by the letter x.
In this example embodiment, the calculation of the first output value to obtain the plurality of second output values may be implemented as follows: the first output value is gradually increased by 1 and squared, that is, x is sequentially obtained2,(x+1)2,(x+2)2,(x+3)2,...,(x+t-1)2As each of the second output values.
In this example embodiment, the calculation of the first output value to obtain the plurality of second output values may be further implemented by: calculating to obtain 2x,4x,8x, 2 from the first output value xt-1x, and x,2x,4x,8xt-1And x is sequentially assigned to each second output value.
In addition, the second output values may be obtained by other operations, and also fall within the scope of the present exemplary embodiment.
In step S430, obtaining corresponding prime numbers according to the plurality of second output values; and each prime number is sequentially positioned between two adjacent second output values.
In this example embodiment, each prime number is assigned a prime number from between every two adjacent second output values. The prime number may be a first prime number larger than a latter one of the two adjacent second output values, may be a last prime number smaller than a former one of the two adjacent second output values, and may be a prime number in the middle of the two adjacent second output values. The present exemplary embodiment does not limit this.
In step S440, each prime number is used to balance the first binary information bits to obtain each third output value, and each character of the encrypted string is assigned with a value by using each third output value.
In this exemplary embodiment, the specific implementation of assigning values to the characters of the encrypted character string may be as follows: obtaining third output values by using the obtained prime numbers to carry out complementation on the digits of the first binary information; taking a character string taking the bit number of the encrypted character string as the element number as an assignment character string; using each third output value as a position pointer to obtain characters at corresponding positions in the assignment character string; the individual characters in the encrypted string are assigned values using the characters obtained from the assigned string.
In step S330, the first binary information is encrypted by using the encryption character string to obtain an encrypted picture.
In this example embodiment, the encrypting each first binary information with the encryption string may be implemented by operating on the first binary information using the encryption string. The operation may be a multiplication operation, an exclusive or operation, or other operations that can achieve the same function, and all of them belong to the protection scope of the present exemplary embodiment.
In a specific embodiment of this example embodiment, the method further comprises:
converting the size information of the picture to be encrypted into corresponding second binary information;
and encrypting the second binary information by using the encryption character string.
In the present exemplary embodiment, the size information refers to length and width information of a picture to be encrypted, the size information being in units of pixels. For example, the size of the picture to be encrypted may be 640 × 480 resolution, 1600 × 1200 resolution, or 2048 × 1536 resolution. The higher the resolution, the sharper the picture, and the larger the size of the picture.
In the present exemplary embodiment, the second binary information is to convert the size information of the picture to be encrypted into a binary representation, and the conversion method follows the conversion rule between the binary representations. For example, a 640x480 resolution may be represented using binary length as 1010000000 and width as 111100000; the length for 1600x 1200 resolution is indicated at 11001000000 and the width is indicated at 10010110000.
In the present exemplary embodiment, the manner of obtaining the encrypted string and the process of encrypting the second binary information by using the encrypted string are the same as those in steps S320 and S330, and are not described herein again.
Next, the present exemplary embodiment further provides a picture decryption method, configured to decrypt a picture encrypted by using any specific embodiment of the picture encryption method, as shown in fig. 5, specifically including the following steps:
step S510: acquiring each encrypted first binary information and the password;
step S520: calculating the password by using a decryption function to obtain a decryption character string; wherein the decryption function and the encryption function are the same function;
step S530: and decrypting each first binary information by using the decryption character string to obtain a decrypted picture.
Next, in another embodiment, the above steps are explained in more detail.
In step S510, each encrypted first binary information and the password are obtained.
In the present exemplary embodiment, the form, the number of bits, and the obtaining manner of the password have already been described in the above-mentioned picture encryption method, and are not described herein again.
Step S520: calculating the password by using a decryption function to obtain a decryption character string; wherein the decryption function and the encryption function are the same function;
in this exemplary embodiment, the process of obtaining the decryption string is the same as the process of obtaining the encryption string in the above-mentioned picture encryption algorithm, and is not described herein again.
Step S530: and decrypting each first binary information by using the decryption character string to obtain a decrypted picture.
In this exemplary embodiment, the process of decrypting each first binary information by using the decryption string should be to perform an inverse operation of the encryption operation in the above-mentioned encrypted picture method on each first binary information by using the decryption string.
The following describes the picture encryption and decryption method in this exemplary embodiment with reference to the specific scenarios in fig. 6 to 11. In the application scenario, the color information of each pixel of the picture to be encrypted is calculated using a 24-bit encoded RGB value.
Next, a picture encryption method in this specific application scenario is described in detail with reference to a flow shown in fig. 6:
in step S610, the obtained password is calculated into a 24-bit long character string strArray according to the algorithm in steps S710 to S720 shown in fig. 7, and the method specifically includes:
step S710: four functions S, N, F, Z are defined as follows:
calculating the position sum of each character in the password in unicode coding, then calculating the average value of the position sum and rounding up;
N(x)=x2
f (y) calculating a first prime number greater than y;
c (z) ═ takes the z-th character in the twenty-four system.
Step S720: the four functions defined in step S720 are combined to obtain a composite function, and the 24-bit-length character string strArray is calculated by using the composite function, which is specifically calculated as follows:
strArray [0] ═ C (F (N (S (cipher)))% 24;
strArray [1] ═ C (F (N (S (password) + 1))% 24);
strArray [2] ═ C (F (N (S (password) + 2))% 24);
......
strArray [23] ═ C (F (N (S (password) + 23))% 24).
Step S620: converting the color information of each pixel of the picture to be encrypted into corresponding first binary information;
in step S620, the color information of each pixel of the picture to be encrypted is converted into corresponding first binary information. In the specific scene, taking a red pixel as an example, the color information of the pixel is converted into first binary information. The RGB value of the red pixel is (255,0,0) and the first binary information is represented as (11111111,00000000,00000000).
In step S630, the first binary information is encrypted by using the string strArray obtained in step S610. In this specific scenario, taking a red pixel as an example, the string strArray is used to perform an encryption operation on the first binary information (11111111,00000000,00000000) corresponding to the red pixel as shown in fig. 8.
In step S640, the size information of the picture to be encrypted is converted into second binary information by using a binary conversion rule, and the second binary information is encrypted by using the encryption methods in steps S610 to S630 to obtain an encrypted picture.
Referring to fig. 9, a method for decrypting an image encrypted by the encryption method shown in fig. 8 will be specifically described, and in the specific decryption process, a red pixel is still taken as an example for detailed description. The method mainly comprises the following steps:
in step S910, the password input by the user is calculated into a string strArray method of 24-bit length. In this specific scenario, the password input by the user is the same as the password used by the above-mentioned picture encryption algorithm, and the string strArray method of calculating the password into a length of 24 bits is also consistent with the above-mentioned picture encryption method.
In step S920, the encrypted first binary information is decrypted by using the string strArray obtained in step S610. In the specific scenario, taking a red pixel as an example, the step is specifically to obtain the first binary information obtained after the red pixel is encrypted by using the above-mentioned picture encryption algorithm, and perform the decryption operation on the first binary information as shown in fig. 10.
In step S930, the picture length and width are decrypted by using the decryption function to obtain the original picture. In the specific scene, the step is specifically to acquire the second binary information obtained by encrypting the picture length and width by the picture encryption method, decrypt the second binary information by using the decryption method in steps S910 to S920 to obtain the length and width of the picture, and finally obtain the original picture by combining the color information of each pixel obtained by decryption.
It should be noted that although the various steps of the methods of the present disclosure are depicted in the drawings in a particular order, this does not require or imply that these steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
Further, in this example embodiment, a picture encryption apparatus is also provided. Referring to fig. 11, the picture encryption apparatus 1100 may include an information reading module 1110, a type conversion module 1120, a function operation module 1130, and a picture encryption module 1140. Wherein:
the information reading module 1110 may be configured to obtain a picture to be encrypted and a password;
the type conversion module 1120 can be used for converting the color information of each pixel of the picture to be encrypted into corresponding first binary information;
the function operation module 1130 may be configured to obtain an encrypted string according to the password by using the encryption function;
the picture encryption module 1140 may be configured to perform an encryption operation on the first binary information by using the encryption character string.
In an exemplary embodiment of the disclosure, the function operation module 1130 obtains the encrypted string by: acquiring the position of each character in the password in a coding table and obtaining a first output value according to the acquired position; calculating the first output value by using a prime number distribution rule to obtain a plurality of second output values; the number of the second output values is the same as the number of the bits of the encrypted character string; obtaining corresponding prime numbers according to the second output values; each prime number is sequentially positioned between two adjacent second output values; and carrying out remainder operation on the digits of the first binary information by utilizing each prime number to obtain each third output value, and assigning values to each character of the encrypted character string according to each third output value.
The specific details of each module or unit in the above-mentioned picture encryption apparatus have been described in detail in the corresponding picture encryption method, and therefore are not described herein again.
Accordingly, in the present exemplary embodiment, a picture decryption apparatus is also provided. Referring to fig. 12, the picture encryption apparatus 1200 may include an information reading module 1210, a function operation module 1220, a picture decryption module 1230, and a type conversion module 1240. Wherein:
the information reading module 1210 is configured to obtain each encrypted first binary information and the password corresponding to the picture to be decrypted;
the function operation module 1220 is configured to obtain a decryption string according to the password by using a decryption function;
the picture decryption module 1230 is configured to perform a decryption operation on each encrypted first binary information by using the decryption character string;
the type conversion module 1240 reads out each first binary information obtained by decryption in the form of a picture.
In an exemplary embodiment of the disclosure, the function operation module 1220 obtains the decryption string by: acquiring the position of each character in the password in a coding table and obtaining a first output value according to the acquired position; calculating the first output value by using a prime number distribution rule to obtain a plurality of second output values; the number of the second output values is the same as the number of bits of the decryption character string; obtaining corresponding prime numbers according to the second output values; each prime number is sequentially positioned between two adjacent second output values; and carrying out remainder operation on the digits of the first binary information by utilizing each prime number to obtain each third output value, and assigning values to each character of the decryption character string according to each third output value.
The specific details of each module or unit in the image decryption apparatus have been described in detail in the corresponding image decryption method, and therefore are not described herein again.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
As another aspect, the present application also provides a computer-readable medium, which may be contained in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by an electronic device, cause the electronic device to implement the method as described in the above embodiments. For example, the electronic device may implement the various steps shown in fig. 3-10, and so on.
It should be noted that the computer readable media shown in the present disclosure may be computer readable signal media or computer readable storage media or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer-readable signal medium may include a propagated data signal with computer-readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (12)

1. A picture encryption method, comprising:
converting the color information of each pixel of the picture to be encrypted into corresponding first binary information;
acquiring a password and operating the password by using an encryption function to obtain an encrypted character string; the bit number of the encrypted character string is the same as the bit number of each piece of first binary information;
and encrypting each first binary information by using the encryption character string to obtain an encrypted picture.
2. The picture encryption method according to claim 1, further comprising:
converting the size information of the picture to be encrypted into corresponding second binary information;
and encrypting the second binary information by using the encryption character string.
3. The picture encryption method according to claim 1, wherein the obtaining of the password and the operation of the password by using the encryption function to obtain the encrypted character string comprises:
acquiring the position of each character in the password in a coding table and obtaining a first output value according to the acquired position;
calculating the first output value by using a prime number distribution rule to obtain a plurality of second output values; the number of the second output values is the same as the number of the bits of the encrypted character string;
obtaining corresponding prime numbers according to the second output values; each prime number is sequentially positioned between two adjacent second output values;
and carrying out remainder operation on the digits of the first binary information by utilizing each prime number to obtain each third output value, and assigning values to each character of the encrypted character string according to each third output value.
4. The method for encrypting the picture according to claim 3, wherein the obtaining the position of each character in the password in the coding table and obtaining the first output value according to the obtained position comprises:
and calculating the sum of the positions of each character of the password in a coding table, calculating an average value, and rounding up the average value to obtain a first output value.
5. The method according to claim 3, wherein the calculating the first output value using a prime distribution rule to obtain a plurality of second output values comprises:
adding an integer to the first output value, squaring the sum, and assigning the result to a plurality of second output values; and the integers are all integers in a front closing and rear opening interval from 0 to the bit number of the encrypted character string in sequence.
6. The method according to claim 3, wherein the performing a remainder operation on the digits of the first binary information by using each of the prime numbers to obtain each of third output values, and assigning values to each of the characters of the encrypted string according to each of the third output values comprises:
taking a character string taking the bit number of the encrypted character string as the element number as an assignment character string;
using each third output value as a position pointer to obtain characters at corresponding positions in the assignment character string;
assigning a value to each character in the encrypted string using the character obtained from the assigned string.
7. The method according to claim 3, wherein the encrypting the first binary information by using the encryption string to obtain the encrypted picture comprises:
and multiplying each first binary information by using the encryption character string to obtain an encrypted picture.
8. A picture decryption method for decrypting a picture encrypted by the picture encryption method according to any one of claims 1 to 7, comprising:
acquiring each encrypted first binary information and the password;
calculating the password by using a decryption function to obtain a decryption character string; wherein the decryption function and the encryption function are the same function;
and decrypting each first binary information by using the decryption character string to obtain a decrypted picture.
9. A picture encryption apparatus, comprising:
the information reading module is used for acquiring a picture to be encrypted and a password;
the type conversion module is used for converting the color information of each pixel of the picture to be encrypted into corresponding first binary information;
the function operation module is used for acquiring an encryption character string by using the encryption function according to the password;
and the picture encryption module is used for carrying out encryption operation on each first binary information by using the encryption character string.
10. A picture decrypting apparatus for decrypting a picture encrypted by the picture encrypting apparatus according to claim 9, comprising:
the information reading module is used for acquiring each encrypted first binary information and the password corresponding to the picture to be decrypted;
the function operation module is used for acquiring a decryption character string by using a decryption function according to the password;
the picture decryption module is used for decrypting each encrypted first binary information by using the decryption character string;
and the type conversion module is used for reading the first binary information obtained by decryption in a picture form.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of any one of claims 1 to 8.
12. An electronic device, comprising:
a processor;
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the method of any of claims 1-8 via execution of the executable instructions.
CN201910750377.1A 2019-08-14 2019-08-14 Picture encryption and decryption method and device, storage medium and electronic equipment Active CN112399027B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910750377.1A CN112399027B (en) 2019-08-14 2019-08-14 Picture encryption and decryption method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910750377.1A CN112399027B (en) 2019-08-14 2019-08-14 Picture encryption and decryption method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN112399027A true CN112399027A (en) 2021-02-23
CN112399027B CN112399027B (en) 2023-12-05

Family

ID=74601407

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910750377.1A Active CN112399027B (en) 2019-08-14 2019-08-14 Picture encryption and decryption method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN112399027B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113343287A (en) * 2021-08-09 2021-09-03 中建电子商务有限责任公司 E-commerce platform picture data extraction method and system based on artificial intelligence
CN115174758A (en) * 2022-06-06 2022-10-11 中国电信股份有限公司 Picture encryption method and device, electronic equipment and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1248365A (en) * 1997-01-14 2000-03-22 张景隆 Method and apparatus for robust high-speed cryptosystem
JP2005130404A (en) * 2003-10-27 2005-05-19 Nippon Telegr & Teleph Corp <Ntt> Restoration-controlled type confidential information distributing method, restoration-controlled secret information distributing apparatus, restoration-controlled confidential information distributing program and recording medium therefor
US20080162484A1 (en) * 2006-12-27 2008-07-03 Ryo Yoshida Technique for controlling access to data
CA2754370A1 (en) * 2011-10-07 2013-04-07 Revere Security Corporation Method and device for data encryption and decryption
CN103684760A (en) * 2012-09-24 2014-03-26 腾讯科技(深圳)有限公司 Method, device and system for encryption and decryption of communication
CN107276998A (en) * 2017-06-07 2017-10-20 广州华多网络科技有限公司 A kind of performance optimization method and device based on OpenSSL
CN108055121A (en) * 2017-10-23 2018-05-18 北京邮电大学 The encryption method and decryption method of image
CN108513135A (en) * 2017-02-27 2018-09-07 诺基亚技术有限公司 Image encryption and decryption
CN109302282A (en) * 2018-08-28 2019-02-01 浙江工业大学 A kind of trade secret sending method based on data encryption technology

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1248365A (en) * 1997-01-14 2000-03-22 张景隆 Method and apparatus for robust high-speed cryptosystem
JP2005130404A (en) * 2003-10-27 2005-05-19 Nippon Telegr & Teleph Corp <Ntt> Restoration-controlled type confidential information distributing method, restoration-controlled secret information distributing apparatus, restoration-controlled confidential information distributing program and recording medium therefor
US20080162484A1 (en) * 2006-12-27 2008-07-03 Ryo Yoshida Technique for controlling access to data
CA2754370A1 (en) * 2011-10-07 2013-04-07 Revere Security Corporation Method and device for data encryption and decryption
CN103684760A (en) * 2012-09-24 2014-03-26 腾讯科技(深圳)有限公司 Method, device and system for encryption and decryption of communication
CN108513135A (en) * 2017-02-27 2018-09-07 诺基亚技术有限公司 Image encryption and decryption
CN107276998A (en) * 2017-06-07 2017-10-20 广州华多网络科技有限公司 A kind of performance optimization method and device based on OpenSSL
CN108055121A (en) * 2017-10-23 2018-05-18 北京邮电大学 The encryption method and decryption method of image
CN109302282A (en) * 2018-08-28 2019-02-01 浙江工业大学 A kind of trade secret sending method based on data encryption technology

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王大鹏: "军队互联网环境中安全电子邮件系统模型设计_王大鹏", CNKI *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113343287A (en) * 2021-08-09 2021-09-03 中建电子商务有限责任公司 E-commerce platform picture data extraction method and system based on artificial intelligence
CN113343287B (en) * 2021-08-09 2021-10-22 中建电子商务有限责任公司 E-commerce platform picture data extraction method and system based on artificial intelligence
CN115174758A (en) * 2022-06-06 2022-10-11 中国电信股份有限公司 Picture encryption method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112399027B (en) 2023-12-05

Similar Documents

Publication Publication Date Title
Abdullah et al. New approaches to encrypt and decrypt data in image using cryptography and steganography algorithm
US10853917B2 (en) Color image authentication method based on palette compression technique
CN112399027B (en) Picture encryption and decryption method and device, storage medium and electronic equipment
CN109613990A (en) Soft keyboard secured inputting method, server, client, electronic equipment and medium
US9813762B2 (en) Creating hash values indicative of differences in images
CN111222611B (en) Color-based stacked three-dimensional code encoding method, encoding device, decoding method, decoding device and storage medium
CN110232284B (en) Image encryption method and device
CN112054896A (en) White box encryption method, device, terminal and storage medium
CN112529974B (en) Color visual password sharing method and device for binary image
CN114785524A (en) Electronic seal generation method, device, equipment and medium
Pande et al. Visual cryptography schemes using compressed random shares
Lin et al. Natural language letter based visual cryptography scheme
CN113298687B (en) Watermark image adding method and device
CN110751251A (en) Method and device for generating and transforming two-dimensional code image matrix
CN115550030A (en) Data encryption method and device, storage medium and electronic equipment
CN111130791A (en) Data signature method, electronic device and computer readable storage medium
AlKhafaji et al. Improved technique for hiding data in a colored and a monochrome image
CN115834025A (en) Data encryption method, equipment and storage medium for automobile diagnosis platform
CN114915464A (en) Image encryption method and image decryption method based on special matrix operation
Chang et al. Distortion-free data embedding scheme for high dynamic range images
CN113672954A (en) Feature extraction method and device and electronic equipment
CN116847036B (en) Image display method, apparatus, electronic device, and computer-readable medium
Zhao An improved scheme for image scaling, cropping and colour correction in encrypted domain
CN114169000A (en) Irreversible data encryption method and related equipment
Trivedi et al. User data privacy in multimedia domain using 3–3 LSB-based color image steganography with RC4 and Bernoulli map protection

Legal Events

Date Code Title Description
PB01 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