CN116545689A - Image encryption and decryption method, device, equipment and medium - Google Patents

Image encryption and decryption method, device, equipment and medium Download PDF

Info

Publication number
CN116545689A
CN116545689A CN202310495534.5A CN202310495534A CN116545689A CN 116545689 A CN116545689 A CN 116545689A CN 202310495534 A CN202310495534 A CN 202310495534A CN 116545689 A CN116545689 A CN 116545689A
Authority
CN
China
Prior art keywords
key
image
ciphertext
aes
encryption
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.)
Pending
Application number
CN202310495534.5A
Other languages
Chinese (zh)
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.)
Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Original Assignee
Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center 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 Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd filed Critical Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Priority to CN202310495534.5A priority Critical patent/CN116545689A/en
Publication of CN116545689A publication Critical patent/CN116545689A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • H04L63/045Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply hybrid encryption, i.e. combination of symmetric and asymmetric encryption
    • 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
    • H04N1/4446Hiding of documents or document information
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Multimedia (AREA)
  • Facsimile Transmission Control (AREA)

Abstract

The invention provides a method, a device, equipment and a readable medium for encrypting and decrypting an image, wherein the method comprises the following steps: generating a first ciphertext from the pre-encrypted image and the key image; performing AES encryption on the first ciphertext by using the AES key to generate a second ciphertext; performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to an encrypted image decryption end; in response to receiving a request to decrypt the encrypted image, the encrypted image is decrypted using the private key corresponding to the public key, the key image, and the AES key to obtain a decrypted image. By using the scheme of the invention, the correlation between adjacent pixels of the encrypted image can be destroyed, the calculated amount of the encryption process can be reduced, and the full performance of image encryption can be improved.

Description

Image encryption and decryption method, device, equipment and medium
Technical Field
The present invention relates to the field of computers, and more particularly, to a method, apparatus, device, and readable medium for encrypting and decrypting an image.
Background
The image can be encrypted by using an AES (Advanced Encryption Standard, advanced encryption standard, a symmetric encryption algorithm) encryption and decryption algorithm, but the effect of directly encrypting the image by using the AES encryption and decryption algorithm is bad, because the sequence of the encrypted pixels is not changed, or the outline of an object in the image can be outlined, that is, although the AES can directly encrypt the image, the correlation between adjacent pixels is strong, and after the AES is used for encrypting, the strong correlation still exists, so that a certain potential safety hazard exists.
Disclosure of Invention
In view of the above, an object of the embodiments of the present invention is to provide a method, apparatus, device and readable medium for encrypting and decrypting an image, by using the technical solution of the present invention, the correlation between adjacent pixels of the encrypted image can be destroyed, the calculation amount in the encryption process can be reduced, and the overall performance of image encryption can be improved.
Based on the above object, an aspect of the embodiments of the present invention provides a method for encrypting and decrypting an image, including the steps of:
generating a first ciphertext from the pre-encrypted image and the key image;
performing AES encryption on the first ciphertext by using the AES key to generate a second ciphertext;
performing RSA (an asymmetric encryption algorithm) encryption on the key image and the AES key by using the public key to generate a third ciphertext, and sending the second ciphertext and the third ciphertext to an encrypted image decryption end;
in response to receiving a request to decrypt the encrypted image, the encrypted image is decrypted using the private key corresponding to the public key, the key image, and the AES key to obtain a decrypted image.
According to one embodiment of the invention, generating the first ciphertext from the pre-encrypted image and the key image comprises:
randomly generating a key image with the same size as the pre-encrypted image;
and performing bit exclusive OR operation on the pre-encrypted image and the key image to obtain a first ciphertext.
According to one embodiment of the invention, generating the second ciphertext by AES encrypting the first ciphertext using the AES key comprises:
randomly generating an AES key;
and performing AES encryption on the first ciphertext by using the randomly generated AES key to obtain a second ciphertext.
According to one embodiment of the invention, the randomly generated AES key is a 128 bit or 192 bit or 256 bit key.
According to one embodiment of the present invention, RSA encrypting the key image and the AES key using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to the encrypted image decryption side includes:
obtaining a public key published by an encrypted image decryption end;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext;
and sending the second ciphertext and the third ciphertext to an encrypted image decryption end.
According to one embodiment of the present invention, in response to receiving a request to decrypt an encrypted image, decrypting using a private key corresponding to a public key, a key image, and an AES key to obtain a decrypted image includes:
in response to receiving a request for decrypting the encrypted image, the decryption end decrypts the third ciphertext by using a private key corresponding to the public key to obtain an AES key and a key image;
decrypting the second ciphertext by using the AES key to obtain a first ciphertext;
and decrypting the first ciphertext by using the key image to obtain a decrypted image.
According to one embodiment of the present invention, decrypting the first ciphertext using the key image to obtain a decrypted image includes:
and performing exclusive OR operation on the key image and the first ciphertext to obtain a decrypted image.
In another aspect of the embodiment of the present invention, there is also provided an apparatus for encrypting and decrypting an image, including:
a first encryption module configured to generate a first ciphertext from the pre-encrypted image and the key image;
the second encryption module is configured to carry out AES encryption on the first ciphertext by using the AES key to generate a second ciphertext;
the third encryption module is configured to perform RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and send the second ciphertext and the third ciphertext to the encrypted image decryption end;
and the decryption module is configured to decrypt the encrypted image by using the private key, the key image and the AES key corresponding to the public key in response to receiving the request for decrypting the encrypted image, so as to obtain a decrypted image.
In another aspect of the embodiments of the present invention, there is also provided a computer apparatus including:
at least one processor; and
and a memory storing computer instructions executable on the processor, the instructions when executed by the processor performing the steps of any of the methods described above.
In another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of any of the methods described above.
The invention has the following beneficial technical effects: the image encryption and decryption method provided by the embodiment of the invention generates a first ciphertext by pre-encrypting the image and the key image; performing AES encryption on the first ciphertext by using the AES key to generate a second ciphertext; performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to an encrypted image decryption end; in response to receiving a request for decrypting an encrypted image, the technical scheme of decrypting the encrypted image by using a private key corresponding to the public key, a key image and an AES key to obtain the decrypted image can destroy the correlation between adjacent pixels of the encrypted image, reduce the calculation amount of the encryption process and improve the full performance of image encryption.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are necessary for the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention and that other embodiments may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a method of encrypting and decrypting an image according to one embodiment of the invention;
FIG. 2 is a schematic diagram of a method for encrypting and decrypting an image according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an apparatus for encrypting and decrypting an image according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a computer device according to one embodiment of the invention;
fig. 5 is a schematic diagram of a computer-readable storage medium according to one embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention will be described in further detail with reference to the accompanying drawings.
Based on the above object, in a first aspect of the embodiments of the present invention, an embodiment of a method for encrypting and decrypting an image is provided. Fig. 1 shows a schematic flow chart of the method.
As shown in fig. 1, the method may include the steps of:
s1, generating a first ciphertext from the pre-encrypted image and the key image. Firstly, preprocessing an image to be encrypted, namely performing bitwise exclusive OR operation with a randomly generated key image, and breaking correlation among pixels. And randomly generating a key image with the same size as the pre-encrypted image, and then carrying out bit exclusive OR operation on the pre-encrypted image and the key image to obtain a first ciphertext.
S2, performing AES encryption on the first ciphertext by using the AES key to generate a second ciphertext. And randomly generating an AES key, and performing AES encryption on the first ciphertext by using the randomly generated AES key to obtain a second ciphertext. The AES algorithm inputs 128 bits of plaintext, the input Key is of variable length, and because the AES algorithm Key is of very long length, the AES algorithm can well resist attack of an exhaustion Key, and also can effectively resist linear attack, differential attack, etc., the AES algorithm mainly has four operation processes, namely a Key addition layer (also called Round Key addition, english Add Round Key), a byte substitution layer (SubByte), a Shift row layer (Shift Rows), and a Mix Column layer (Mix Column).
S3, RSA encryption is carried out on the key image and the AES key by using the public key to generate a third ciphertext, and the second ciphertext and the third ciphertext are sent to an encrypted image decryption end. The decryption end (the receiver of the image) publishes a public key, meanwhile, a private key Prikey which is known by the receiver is reserved, the encryption end obtains the public key published by the decryption end, then RSA encryption is carried out on the key image and the AES key by using the public key to generate a third ciphertext, and then the second ciphertext and the third ciphertext are sent to the encrypted image decryption end. The RSA algorithm itself is based on a simple knowledge of the number theory, giving two primes which can be easily multiplied, but given their product, it is particularly difficult to find the two primes. The algorithm consists of two keys, namely a public key and a private key:
1) Preparing two very large prime numbers p and q;
2) Calculating the product n=pq of the large prime number p and q;
3) Calculating an Euler function of n, and setting the Euler function as m;
4) Finding a number e (1 < e < m), satisfying gcd (m, e) =1 (i.e. e and m are each prime);
5) Calculating the inverse d of e over the modulo-m domain (i.e. satisfying ed mod m=1);
6) So far, the public key and the private key are generated, wherein (n, e) is the public key, and (n, d) is the private key;
for plaintext x, the encryption of x with public key (n, e) is to convert x into numbers, and then calculate y by power modulus, where y is ciphertext; the decryption process is similar to encryption for ciphertext y by decrypting y with the private key (n, d), and is also the calculation of the exponentiation modulus. The RSA algorithm has the advantages of higher security than the AES algorithm, and has the disadvantages of higher calculation amount and low speed. Therefore, the RSA is used for encrypting the AES key and the key image used in preprocessing, so that the calculated amount is not so large, and the safety performance is improved.
S4, in response to receiving a request for decrypting the encrypted image, decrypting the encrypted image by using a private key corresponding to the public key, the key image and the AES key to obtain a decrypted image. When the decryption end is to decrypt the encrypted image, the decryption end uses a private key corresponding to the public key to decrypt the third ciphertext to obtain an AES key and a key image, then uses the AES key to decrypt the second ciphertext to obtain a first ciphertext, and then uses the key image to decrypt the first ciphertext to obtain a decrypted image.
By using the technical scheme of the invention, the correlation between adjacent pixels of the encrypted image can be destroyed, the calculated amount of the encryption process can be reduced, and the full performance of the image encryption can be improved.
In a preferred embodiment of the present invention, generating the first ciphertext from the pre-encrypted image and the key image comprises:
randomly generating a key image with the same size as the pre-encrypted image;
and performing bit exclusive OR operation on the pre-encrypted image and the key image to obtain a first ciphertext. As shown in fig. 2, for example, the picture to be encrypted is P, the sending end needs to encrypt the picture P to be sent, firstly, randomly generate a key image K1 with the same size as the picture P, then perform bitwise exclusive or operation on P and K1 to obtain a first ciphertext M1, where the first ciphertext M1 breaks the correlation between pixels, and the outline of an object in the image cannot be seen, so that the security of the encrypted image is increased.
In a preferred embodiment of the present invention, generating the second ciphertext by AES encrypting the first ciphertext using the AES key comprises:
randomly generating an AES key;
and performing AES encryption on the first ciphertext by using the randomly generated AES key to obtain a second ciphertext. The transmitting end carries out AES encryption on M1, the AES key is randomly generated K2, K2 can be 128 bits, 192 bits or 256 bits, the ciphertext after AES encryption is second ciphertext M2, and the process of encrypting the image can be expressed as follows: m2=aes (xor (P, K1)), where xor represents a bitwise exclusive-or operation, and M2 is the final desired ciphertext.
In a preferred embodiment of the invention, the randomly generated AES key is a 128 bit or 192 bit or 256 bit key.
In a preferred embodiment of the present invention, RSA encrypting the key image and the AES key using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to the encrypted image decryption side includes:
obtaining a public key published by an encrypted image decryption end;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext;
and sending the second ciphertext and the third ciphertext to an encrypted image decryption end. The decryption end publishes a public key, simultaneously reserves a private key Prikey which is known only by the decryption end, a sender obtains the public key, uses the public key to carry out RSA encryption on K1 and K2 of the sender, encrypts the encrypted ciphertext of K1 and K2 to be a third ciphertext Key M, and then transmits the Key M and M2 to the decryption end.
In a preferred embodiment of the present invention, in response to receiving a request to decrypt an encrypted image, decrypting using a private key corresponding to a public key, a key image, and an AES key to obtain a decrypted image includes:
in response to receiving a request for decrypting the encrypted image, the decryption end decrypts the third ciphertext by using a private key corresponding to the public key to obtain an AES key and a key image;
decrypting the second ciphertext by using the AES key to obtain a first ciphertext;
and decrypting the first ciphertext by using the key image to obtain a decrypted image. When the decryption end is to decrypt the encrypted image, the decryption end uses the private key Prikey to decrypt the third ciphertext to obtain an AES key and a key image, then uses the AES key to decrypt the second ciphertext to obtain a first ciphertext, and finally uses the key image to decrypt the first ciphertext to obtain a decrypted image.
In a preferred embodiment of the present invention, decrypting the first ciphertext using the key image to obtain a decrypted image includes:
and performing exclusive OR operation on the key image and the first ciphertext to obtain a decrypted image.
The invention provides a solution to the problem that the image encryption based on the AES algorithm can display the outline, namely, the image is preprocessed before the image is subjected to the AES encryption, so that the correlation among pixels can be destroyed, in addition, the AES algorithm has the defects that encryption and decryption share a set of keys, the risk of leakage exists, the RSA algorithm has the defects of large calculated amount and low operation speed, so that the AES keys are encrypted by the RSA algorithm and the key images used in the preprocessing are preprocessed, the calculated amount is not so large, and meanwhile, the safety of the image encryption is improved.
It should be noted that, it will be understood by those skilled in the art that all or part of the procedures in implementing the methods of the above embodiments may be implemented by a computer program to instruct related hardware, and the above program may be stored in a computer readable storage medium, and the program may include the procedures of the embodiments of the above methods when executed. Wherein the storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like. The computer program embodiments described above may achieve the same or similar effects as any of the method embodiments described above.
Furthermore, the method disclosed according to the embodiment of the present invention may also be implemented as a computer program executed by a CPU, which may be stored in a computer-readable storage medium. When executed by a CPU, performs the functions defined above in the methods disclosed in the embodiments of the present invention.
In view of the above object, a second aspect of the embodiments of the present invention provides an apparatus for encrypting and decrypting an image, as shown in fig. 3, the apparatus 200 includes:
a first encryption module configured to generate a first ciphertext from the pre-encrypted image and the key image;
the second encryption module is configured to carry out AES encryption on the first ciphertext by using the AES key to generate a second ciphertext;
the third encryption module is configured to perform RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and send the second ciphertext and the third ciphertext to the encrypted image decryption end;
and the decryption module is configured to decrypt the encrypted image by using the private key, the key image and the AES key corresponding to the public key in response to receiving the request for decrypting the encrypted image, so as to obtain a decrypted image.
In a preferred embodiment of the invention, the first encryption module is further configured to:
randomly generating a key image with the same size as the pre-encrypted image;
and performing bit exclusive OR operation on the pre-encrypted image and the key image to obtain a first ciphertext.
In a preferred embodiment of the invention, the second encryption module is further configured to:
randomly generating an AES key;
and performing AES encryption on the first ciphertext by using the randomly generated AES key to obtain a second ciphertext.
In a preferred embodiment of the invention, the randomly generated AES key is a 128 bit or 192 bit or 256 bit key.
In a preferred embodiment of the invention, the third encryption module is further configured to:
obtaining a public key published by an encrypted image decryption end;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext;
and sending the second ciphertext and the third ciphertext to an encrypted image decryption end.
In a preferred embodiment of the invention, the decryption module is further configured to:
in response to receiving a request for decrypting the encrypted image, the decryption end decrypts the third ciphertext by using a private key corresponding to the public key to obtain an AES key and a key image;
decrypting the second ciphertext by using the AES key to obtain a first ciphertext;
and decrypting the first ciphertext by using the key image to obtain a decrypted image.
In a preferred embodiment of the invention, the decryption module is further configured to:
and performing exclusive OR operation on the key image and the first ciphertext to obtain a decrypted image.
By using the technical scheme of the invention, the correlation between adjacent pixels of the encrypted image can be destroyed, the calculated amount of the encryption process can be reduced, and the full performance of the image encryption can be improved.
Based on the above object, a third aspect of the embodiments of the present invention proposes a computer device. Fig. 4 is a schematic diagram of an embodiment of a computer device provided by the present invention. As shown in fig. 4, an embodiment of the present invention includes the following means: at least one processor 21; and a memory 22, the memory 22 storing computer instructions 23 executable on the processor, the instructions when executed by the processor performing the method of:
generating a first ciphertext from the pre-encrypted image and the key image;
performing AES encryption on the first ciphertext by using the AES key to generate a second ciphertext;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to an encrypted image decryption end;
in response to receiving a request to decrypt the encrypted image, the encrypted image is decrypted using the private key corresponding to the public key, the key image, and the AES key to obtain a decrypted image.
In a preferred embodiment of the present invention, generating the first ciphertext from the pre-encrypted image and the key image comprises:
randomly generating a key image with the same size as the pre-encrypted image;
and performing bit exclusive OR operation on the pre-encrypted image and the key image to obtain a first ciphertext.
In a preferred embodiment of the present invention, generating the second ciphertext by AES encrypting the first ciphertext using the AES key comprises:
randomly generating an AES key;
and performing AES encryption on the first ciphertext by using the randomly generated AES key to obtain a second ciphertext.
In a preferred embodiment of the invention, the randomly generated AES key is a 128 bit or 192 bit or 256 bit key.
In a preferred embodiment of the present invention, RSA encrypting the key image and the AES key using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to the encrypted image decryption side includes:
obtaining a public key published by an encrypted image decryption end;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext;
and sending the second ciphertext and the third ciphertext to an encrypted image decryption end.
In a preferred embodiment of the present invention, in response to receiving a request to decrypt an encrypted image, decrypting using a private key corresponding to a public key, a key image, and an AES key to obtain a decrypted image includes:
in response to receiving a request for decrypting the encrypted image, the decryption end decrypts the third ciphertext by using a private key corresponding to the public key to obtain an AES key and a key image;
decrypting the second ciphertext by using the AES key to obtain a first ciphertext;
and decrypting the first ciphertext by using the key image to obtain a decrypted image.
In a preferred embodiment of the present invention, decrypting the first ciphertext using the key image to obtain a decrypted image includes:
and performing exclusive OR operation on the key image and the first ciphertext to obtain a decrypted image.
By using the technical scheme of the invention, the correlation between adjacent pixels of the encrypted image can be destroyed, the calculated amount of the encryption process can be reduced, and the full performance of the image encryption can be improved.
Based on the above object, a fourth aspect of the embodiments of the present invention proposes a computer-readable storage medium. Fig. 5 is a schematic diagram showing an embodiment of a computer-readable storage medium provided by the present invention. As shown in fig. 5, the computer-readable storage medium 31 stores a computer program 32 that, when executed by a processor, performs the following method:
generating a first ciphertext from the pre-encrypted image and the key image;
performing AES encryption on the first ciphertext by using the AES key to generate a second ciphertext;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to an encrypted image decryption end;
in response to receiving a request to decrypt the encrypted image, the encrypted image is decrypted using the private key corresponding to the public key, the key image, and the AES key to obtain a decrypted image.
In a preferred embodiment of the present invention, generating the first ciphertext from the pre-encrypted image and the key image comprises:
randomly generating a key image with the same size as the pre-encrypted image;
and performing bit exclusive OR operation on the pre-encrypted image and the key image to obtain a first ciphertext.
In a preferred embodiment of the present invention, generating the second ciphertext by AES encrypting the first ciphertext using the AES key comprises:
randomly generating an AES key;
and performing AES encryption on the first ciphertext by using the randomly generated AES key to obtain a second ciphertext.
In a preferred embodiment of the invention, the randomly generated AES key is a 128 bit or 192 bit or 256 bit key.
In a preferred embodiment of the present invention, RSA encrypting the key image and the AES key using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to the encrypted image decryption side includes:
obtaining a public key published by an encrypted image decryption end;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext;
and sending the second ciphertext and the third ciphertext to an encrypted image decryption end.
In a preferred embodiment of the present invention, in response to receiving a request to decrypt an encrypted image, decrypting using a private key corresponding to a public key, a key image, and an AES key to obtain a decrypted image includes:
in response to receiving a request for decrypting the encrypted image, the decryption end decrypts the third ciphertext by using a private key corresponding to the public key to obtain an AES key and a key image;
decrypting the second ciphertext by using the AES key to obtain a first ciphertext;
and decrypting the first ciphertext by using the key image to obtain a decrypted image.
In a preferred embodiment of the present invention, decrypting the first ciphertext using the key image to obtain a decrypted image includes:
and performing exclusive OR operation on the key image and the first ciphertext to obtain a decrypted image.
By using the technical scheme of the invention, the correlation between adjacent pixels of the encrypted image can be destroyed, the calculated amount of the encryption process can be reduced, and the full performance of the image encryption can be improved.
Furthermore, the method disclosed according to the embodiment of the present invention may also be implemented as a computer program executed by a processor, which may be stored in a computer-readable storage medium. The above-described functions defined in the methods disclosed in the embodiments of the present invention are performed when the computer program is executed by a processor.
Furthermore, the above-described method steps and system units may also be implemented using a controller and a computer-readable storage medium storing a computer program for causing the controller to implement the above-described steps or unit functions.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general purpose or special purpose computer or general purpose or special purpose processor. Further, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that as used herein, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The foregoing embodiment of the present invention has been disclosed with reference to the number of embodiments for the purpose of description only, and does not represent the advantages or disadvantages of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, and the program may be stored in a computer readable storage medium, where the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will appreciate that: the above discussion of any embodiment is merely exemplary and is not intended to imply that the scope of the disclosure of embodiments of the invention, including the claims, is limited to such examples; combinations of features of the above embodiments or in different embodiments are also possible within the idea of an embodiment of the invention, and many other variations of the different aspects of the embodiments of the invention as described above exist, which are not provided in detail for the sake of brevity. Therefore, any omission, modification, equivalent replacement, improvement, etc. of the embodiments should be included in the protection scope of the embodiments of the present invention.

Claims (10)

1. An image encryption and decryption method is characterized by comprising the following steps:
generating a first ciphertext from the pre-encrypted image and the key image;
performing AES encryption on the first ciphertext by using the AES key to generate a second ciphertext;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to an encrypted image decryption end;
in response to receiving a request to decrypt the encrypted image, the encrypted image is decrypted using the private key corresponding to the public key, the key image, and the AES key to obtain a decrypted image.
2. The method of claim 1, wherein generating the first ciphertext from the pre-encrypted image and the key image comprises:
randomly generating a key image with the same size as the pre-encrypted image;
and performing bit exclusive OR operation on the pre-encrypted image and the key image to obtain a first ciphertext.
3. The method of claim 1, wherein AES encrypting the first ciphertext using the AES key to generate the second ciphertext comprises:
randomly generating an AES key;
and performing AES encryption on the first ciphertext by using the randomly generated AES key to obtain a second ciphertext.
4. A method according to claim 3, wherein the randomly generated AES key is a 128 bit or 192 bit or 256 bit key.
5. The method of claim 1, wherein RSA encrypting the key image and the AES key using the public key to generate a third ciphertext, and transmitting the second ciphertext and the third ciphertext to the encrypted image decryption side comprises:
obtaining a public key published by an encrypted image decryption end;
performing RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext;
and sending the second ciphertext and the third ciphertext to an encrypted image decryption end.
6. The method of claim 1, wherein decrypting, in response to receiving a request to decrypt the encrypted image, using the private key corresponding to the public key, the key image, and the AES key to obtain a decrypted image comprises:
in response to receiving a request for decrypting the encrypted image, the decryption end decrypts the third ciphertext by using a private key corresponding to the public key to obtain an AES key and a key image;
decrypting the second ciphertext by using the AES key to obtain a first ciphertext;
and decrypting the first ciphertext by using the key image to obtain a decrypted image.
7. The method of claim 6, wherein decrypting the first ciphertext using the key image to obtain a decrypted image comprises:
and performing exclusive OR operation on the key image and the first ciphertext to obtain a decrypted image.
8. An apparatus for encrypting and decrypting an image, the apparatus comprising:
a first encryption module configured to generate a first ciphertext from the pre-encrypted image and the key image;
the second encryption module is configured to carry out AES encryption on the first ciphertext by using the AES key to generate a second ciphertext;
the third encryption module is configured to perform RSA encryption on the key image and the AES key by using the public key to generate a third ciphertext, and send the second ciphertext and the third ciphertext to the encrypted image decryption end;
and a decryption module configured to decrypt, in response to receiving a request to decrypt the encrypted image, using the private key corresponding to the public key, the key image, and the AES key to obtain a decrypted image.
9. A computer device, comprising:
at least one processor; and
a memory storing computer instructions executable on the processor, which when executed by the processor, perform the steps of the method of any one of claims 1-7.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method of any one of claims 1-7.
CN202310495534.5A 2023-04-27 2023-04-27 Image encryption and decryption method, device, equipment and medium Pending CN116545689A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310495534.5A CN116545689A (en) 2023-04-27 2023-04-27 Image encryption and decryption method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310495534.5A CN116545689A (en) 2023-04-27 2023-04-27 Image encryption and decryption method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN116545689A true CN116545689A (en) 2023-08-04

Family

ID=87450023

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310495534.5A Pending CN116545689A (en) 2023-04-27 2023-04-27 Image encryption and decryption method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN116545689A (en)

Similar Documents

Publication Publication Date Title
US8670563B2 (en) System and method for designing secure client-server communication protocols based on certificateless public key infrastructure
US7221757B2 (en) Method and system for accelerated data encryption
US20040174997A1 (en) Key agreement system, shared-key generation apparatus, and shared-key recovery apparatus
US8687812B2 (en) Method and apparatus for public key cryptography
US7986778B2 (en) Cryptographic method and apparatus
JP2015092745A (en) Method of generating encryption/decryption key
US7783045B2 (en) Secure approach to send data from one system to another
KR20150142623A (en) Cryptographic method for securely exchanging messages and device and system for implementing this method
US20110200186A1 (en) Method of cipher block chaining using elliptic curve cryptography
US7779272B2 (en) Hardware cryptographic engine and encryption method
WO2001084766A2 (en) System and method for encryption using transparent keys
CN115567308A (en) Data encryption transmission method based on key expansion
CN108599941A (en) Random asymmetries expand byte encryption of communicated data method
Erondu et al. An encryption and decryption model for data security using vigenere with advanced encryption standard
US20020064278A1 (en) High speed RSA public key cryptographic apparatus and method
CN116545689A (en) Image encryption and decryption method, device, equipment and medium
US20230216659A1 (en) Method for processing encrypted data
CN111488618B (en) Block chain-based one-time pad encryption method, device and storage medium
WO2006073200A1 (en) Communication system and communication method
Hussein et al. An enhanced ElGamal cryptosystem for image encryption and decryption
KR100388059B1 (en) Data encryption system and its method using asymmetric key encryption algorithm
CN109361506B (en) Information processing method
JP2004246350A (en) Enciphering device, deciphering device, enciphering system equipped with the same, enciphering method, and deciphering method
Dũng Variant of OTP Cipher with Symmetric Key Solution
AU2002323203B2 (en) Method and system for accelerated data encryption

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