CN111131270A - Data encryption and decryption method and device, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN111131270A
CN111131270A CN201911373522.5A CN201911373522A CN111131270A CN 111131270 A CN111131270 A CN 111131270A CN 201911373522 A CN201911373522 A CN 201911373522A CN 111131270 A CN111131270 A CN 111131270A
Authority
CN
China
Prior art keywords
color value
data set
picture
data
key
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
CN201911373522.5A
Other languages
Chinese (zh)
Other versions
CN111131270B (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.)
Wuba Co Ltd
Original Assignee
Wuba 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 Wuba Co Ltd filed Critical Wuba Co Ltd
Priority to CN201911373522.5A priority Critical patent/CN111131270B/en
Publication of CN111131270A publication Critical patent/CN111131270A/en
Application granted granted Critical
Publication of CN111131270B publication Critical patent/CN111131270B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/0435Network 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 symmetric encryption, i.e. same key used for encryption and decryption
    • 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
    • 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
    • H04L9/0872Generation of secret information including derivation or calculation of cryptographic keys or passwords using geo-location information, e.g. location data, time, relative position or proximity to other entities

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • Storage Device Security (AREA)

Abstract

The method comprises the steps of firstly generating a position data set according to a preset picture library, then obtaining a color value data set according to the position data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set, encrypting data to be sent according to the color value data set to obtain a ciphertext, and finally sending the ciphertext and the position data set to a receiving end. In the method, the sending end uses the picture resource consistent with the receiving end as the key source to realize the dynamic generation of the key, and the receiving end obtains the key used by the sending end according to the position data set used by the sending end and the picture resource consistent with the sending end, and the key is used for decrypting the ciphertext, so that the symmetric encryption is realized, and the higher security is realized.

Description

Data encryption and decryption method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of data encryption technologies, and in particular, to a method and an apparatus for encrypting and decrypting data, an electronic device, and a storage medium.
Background
In a communication system, plaintext refers to an unencrypted bit stream, such as text, bitmap, digitized voice or video image, and the like. Information may be obtained from the plaintext by some published encoding standard. The plaintext is processed through an encryption algorithm to generate a ciphertext, and the ciphertext is decrypted through a corresponding decryption algorithm to obtain the plaintext.
Data is transmitted from a transmitting end to a receiving end through a network, and in the transmission process, if data is encrypted, data leakage can be effectively prevented. Symmetric encryption is a commonly used data encryption method, in which a sending end needs to encrypt and send data by using a secret key unknown to a third party, and a receiving end uses the same secret key as the sending end to decrypt.
However, in order to enable the receiving end to obtain the key used by the transmitting end to encrypt the data, the above symmetric encryption method requires that the transmitting and receiving ends negotiate in advance and maintain the same key bank, and the key in the key bank is not known to the third party. The huge number of keys makes the distribution and management of the keys very difficult, once the poor management causes the key bank of one party to be revealed, the decryption of the ciphertext can be completed through limited attempts, and the data disclosure is caused.
Disclosure of Invention
The application provides a data encryption and decryption method, a data encryption and decryption device, an electronic device and a storage medium, and aims to solve the problem that an existing symmetric encryption method is low in security.
In a first aspect, the present application provides a data encryption method, applied to a sending end, where the method includes:
generating a position data set according to a preset picture library, wherein the picture library comprises at least one picture, the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture;
acquiring a color value dataset according to the position dataset, wherein the color value dataset comprises color value data of pixel points represented by each group of position data in the position dataset;
and encrypting the data to be sent according to the color value data set to obtain a ciphertext, and sending the ciphertext and the position data set to a receiving end.
Further, each group of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the obtaining a color value dataset from a position dataset comprises:
acquiring a target picture from the picture library according to the picture identification;
and acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identification.
Further, the encrypting the data to be transmitted according to the color value data set to obtain a ciphertext includes:
generating a key from the color value dataset;
and encrypting the data to be transmitted by using the secret key and a preset encryption algorithm to obtain a ciphertext.
Further, the generating a key from the color value dataset comprises:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
Further, the generating a key from the color value dataset further comprises:
and converting the digital key into an alphabetic key according to a preset conversion rule.
In a second aspect, the present application further provides a data decryption method, applied to a receiving end, where the method includes:
receiving a ciphertext and a position data set, wherein the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture in a preset picture library; the ciphertext is obtained by encrypting data to be sent by a sending end according to a color value data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set;
acquiring the color value dataset from the position dataset;
and decrypting the ciphertext according to the color value data set.
Further, each group of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the obtaining a color value dataset from a position dataset comprises:
acquiring a target picture from the picture library according to the picture identification;
and acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identification.
Further, the decrypting the ciphertext according to the color value dataset includes:
generating a key from the color value dataset;
and decrypting the ciphertext by using the secret key and a preset decryption algorithm.
Further, the generating a key from the color value dataset comprises:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
Further, the generating a key from the color value dataset further comprises:
and converting the digital key into an alphabetic key according to a preset conversion rule.
In a third aspect, the present application further provides a data encryption apparatus, applied to a sending end, where the apparatus includes:
the generating module is used for generating a position data set according to a preset picture library, wherein the picture library comprises at least one picture, the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture;
the acquisition module is used for acquiring a color value dataset according to the position dataset, wherein the color value dataset comprises color value data of pixel points represented by each group of position data in the position dataset;
the encryption module is used for encrypting the data to be sent according to the color value data set to obtain a ciphertext;
and the sending module is used for sending the ciphertext and the position data set to a receiving end.
Further, each group of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the acquisition module includes:
the first acquisition unit is used for acquiring a target picture from the picture library according to the picture identifier;
and the second acquisition unit is used for acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identifier.
Further, the encryption module includes:
a generating unit for generating a key from the color value dataset;
and the encryption unit is used for encrypting the data to be transmitted by using the secret key and a preset encryption algorithm to obtain a ciphertext.
Further, the generating unit is specifically configured to:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
Further, the generating unit is further configured to:
and converting the digital key into an alphabetic key according to a preset conversion rule.
In a fourth aspect, the present application further provides a data decryption apparatus, which is applied to a receiving end, and the apparatus includes:
the receiving module is used for receiving the ciphertext and a position data set, wherein the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture in a preset picture library; the ciphertext is obtained by encrypting data to be sent by a sending end according to a color value data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set;
an obtaining module configured to obtain the color value dataset according to the position dataset;
and the decryption module is used for decrypting the ciphertext according to the color value data set.
Further, each group of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the acquisition module includes:
the first acquisition unit is used for acquiring a target picture from the picture library according to the picture identifier;
and the second acquisition unit is used for acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identifier.
Further, the decryption module includes:
a generating unit for generating a key from the color value dataset;
and the decryption unit is used for decrypting the ciphertext by using the secret key and a preset decryption algorithm.
Further, the generating unit is specifically configured to:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
Further, the generating unit is further configured to:
and converting the digital key into an alphabetic key according to a preset conversion rule.
In a fifth aspect, an embodiment of the present application provides an electronic device, including:
a memory for storing program instructions;
a processor for calling and executing the program instructions in the memory to implement the method of the first aspect and/or the second aspect.
In a sixth aspect, this embodiment provides a storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by at least one processor of the apparatus in the third aspect and/or the fourth aspect, the apparatus performs the method in the first aspect and/or the second aspect.
According to the technical scheme, the method comprises the steps of firstly generating a position data set according to a preset picture library, then obtaining a color value data set according to the position data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set, encrypting data to be sent according to the color value data set to obtain a ciphertext, and finally sending the ciphertext and the position data set to a receiving end. In the method, the sending end uses the picture resource consistent with the receiving end as the key source to realize the dynamic generation of the key, and the receiving end obtains the key used by the sending end according to the position data set used by the sending end and the picture resource consistent with the sending end, and the key is used for decrypting the ciphertext, so that the symmetric encryption is realized, and the higher security is realized.
Drawings
In order to more clearly explain the technical solution of the present application, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious to those skilled in the art that other drawings can be obtained according to the drawings without any creative effort.
FIG. 1 is a flow diagram illustrating a method for encrypting data according to an exemplary embodiment of the present application;
FIG. 2 is a schematic diagram illustrating an implementation scenario according to an exemplary embodiment of the present application;
FIG. 3 is a schematic diagram of another implementation scenario illustrated in the present application according to an exemplary embodiment;
FIG. 4 is a flow diagram illustrating a method for decrypting data according to an exemplary embodiment of the present application;
FIG. 5 is a block diagram of a data encryption device according to an exemplary embodiment of the present application;
FIG. 6 is a block diagram of a data decryption device shown in the present application according to an exemplary embodiment;
fig. 7 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Data is transmitted from a transmitting end to a receiving end through a network, and in the transmission process, if data is encrypted, data leakage can be effectively prevented. Conventional symmetric encryption methods require both the sending and receiving parties to negotiate and maintain the same keystore in advance, and the keys in the keystore are not known to third parties. When data transmission is carried out, at a sending end, the sending end firstly obtains a plaintext to be sent, then a secret key is randomly selected from a secret key library, the secret key has a secret key number, then the chosen secret key is used for carrying out encryption processing on the plaintext to obtain a ciphertext, and finally the ciphertext and the secret key number are sent to a receiving end. At a receiving end, the receiving end firstly receives the ciphertext and the key number, then acquires a corresponding key in a key database according to the key number, namely the key used by the sending end, and then decrypts the ciphertext by using the acquired key to obtain a plaintext, thereby acquiring information carried by the plaintext.
The symmetric encryption algorithm has the defects that on one hand, the distribution and management of the secret key are very difficult due to the huge number of the secret keys, and on the other hand, once the secret key library of one party is leaked due to poor management, the decryption of the ciphertext can be completed through limited attempts, so that data leakage is caused.
The existing asymmetric encryption method has higher security compared with the symmetric encryption method. Unlike symmetric encryption methods, asymmetric encryption requires two keys, a public key and a private key, respectively. The public key and the private key need to be used in pairs, i.e., if data is encrypted using the public key, only the private key corresponding to the public key can be used for decryption.
Although the asymmetric encryption method has higher security compared with the symmetric encryption method, the method has long time and low speed for encryption and decryption, and is only suitable for encrypting a small amount of data.
Based on this, the embodiments of the present application provide a data encryption and decryption method, where the method dynamically generates a key based on the same picture resources that both the receiving and the receiving sides respectively possess, so as to implement more secure symmetric encryption, and have the advantages of both symmetric encryption and asymmetric encryption. The following describes in detail a specific implementation of the method of the present application.
Fig. 1 is a flowchart of a data encryption method according to an exemplary embodiment of the present application, which is applied to a sending end, and as shown in fig. 1, the method may include:
step 110, generating a position data set according to a preset picture library, wherein the picture library comprises at least one picture, the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture.
In this embodiment, the same picture library is preset in the sending end and the receiving end respectively, and in practical application, the sending end and the receiving end do not need to additionally preset the picture library, and only need to utilize the picture resources that the two ends originally have stored, for example, under the condition that the sending end and the receiving end both include 58 APP in the same city, the picture built-in 58 APP in the same city can be used as the picture library.
The position data set comprises at least one group of position data, each group of position data comprises a picture identification and at least one position coordinate corresponding to the picture identification, the picture identification is used for uniquely determining one picture in the picture library, and the position coordinate corresponding to the picture identification is used for positioning a pixel point on the picture. That is to say, for a set of position data, when the picture identifier corresponds to one position coordinate data, the set of position data may represent the position of one pixel point on the picture corresponding to the picture identifier, and when the picture identifier corresponds to a plurality of position coordinate data, the set of position data may represent the positions of a plurality of pixel points on the picture corresponding to the picture identifier.
In some embodiments, the location data set may be randomly generated according to a picture library, specifically, one or more pictures are randomly selected from the picture library, for example, "hot @3 x.png" and "hot @3 x" shown in fig. 2 are selected as the picture identifier of the selected picture, then one or more pixel points are randomly selected from the selected picture, and the location coordinates of the selected pixel points are obtained, for example, as shown in fig. 2, the picture size of the picture identifier "hot @3 x" is 84 × 32, and the coordinates of the randomly selected pixel points may be (50 × 13).
In a specific implementation, the position data set may be stored and sent in an array format, each set of position data in the position data set is an element in the array, the key Value of the element is a picture identifier, and the Value of the element is also an array, and the array includes one or more point coordinates.
Illustratively, the data format of a location data set is as follows:
Figure BDA0002340320620000061
Figure BDA0002340320620000071
it can be seen that the position data set includes two sets of position data, the first set of position data represents a pixel point located at a (50 × 13) position on a picture identified as "hot @3 x" in the picture library, and the second set of position data represents a pixel point located at a (102 × 21) position and a pixel point located at a (54 × 79) position on a picture identified as "Rectangle @3 x" in the picture library.
And 120, acquiring a color value data set according to the position data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set.
A picture is composed of pixels, each pixel corresponds to a set of color values, for example, the color value of a pixel (50 × 13) in the picture labeled "hot @3 x" shown in fig. 2 is [ R: 252, G: 89, B: 148], as shown in fig. 3.
Note that, the color value data may also be expressed in hexadecimal, such as [ R: 252, G: 89, B: 148] has a hexadecimal FC5994, where FC is the R value, 59 is the G value, and 94 is the B value.
Based on this, in the case where the position data set is known, the color value data set can be acquired from the position data set. It should be noted that, in the present application, the color value dataset includes color value data of a pixel point represented by each set of position data in the position dataset, where the color value data is specifically an RGB color value shown in fig. 3. And each set of color value data corresponds to one position coordinate in the position data set, or each set of color value data corresponds to one of a plurality of pixel points represented by the position data set.
In a specific implementation, the step of obtaining the color value dataset from the position dataset may include:
firstly, acquiring a target picture from a picture library according to a picture identifier;
then, according to the position coordinate corresponding to the picture identification, color value data of a pixel point corresponding to the position coordinate on the target picture is obtained;
further, the sets of color value data corresponding to the plurality of pixel points form a color value dataset.
Taking the foregoing exemplary position data set as an example, the color value data set obtained from the position data set is as follows:
[{252,89,148},{52,52,51},{41,52,53}]
where {252, 89, 148} is the color value at the (50 × 13) position in the picture "hot @3x }, {52, 52, 51} is the color value at the (102 × 21) position on the picture" Rectangle @3x }, and {41, 52, 53} is the color value at the (54 × 79) position on the picture "Rectangle @3x }.
It can be seen that the order of the color value data in the color value data set coincides with the order of the position coordinates contained in the position data set.
And step 130, encrypting the data to be sent according to the color value data set to obtain a ciphertext, and sending the ciphertext and the position data set to a receiving end.
First, a key to be used for encryption is generated from a color value dataset.
Specifically, the color value data in the color value data set can be spliced end to obtain the digital key. Taking the above exemplary color value data set as an example, the decimal number key obtained by end-to-end splicing is: 25289148525251415253. in some embodiments, the color value data in hexadecimal form can be spliced end to obtain the hexadecimal data key, which is not exemplified here.
After the digital key is obtained, the data to be transmitted can be encrypted by using the digital key and a preset encryption algorithm to obtain a ciphertext. The preset encryption algorithm may be selected from DES, 3DES, TDEA, Blowfish, RC2, RC4, RC5, IDEA, skip jack, and the like, which is not limited in the embodiment of the present application.
In some embodiments, if the preset encryption algorithm does not support the digital key, the digital key may be further converted into an alphabetic key according to a preset conversion rule, and the alphabetic key is used for data encryption. The preset conversion rule is a rule with good pre-agreement of both receiving and sending ends. Taking the above decimal number key as an example, the conversion rule may be: firstly, the R value, the G value and the B value are respectively substituted into 65+ (color value) × 2, then characters corresponding to the calculation results are searched in an ASCII code comparison table, for example, 1 is substituted into 67, the corresponding character is C, 5 is substituted into 75, the corresponding character is K, and so on, thereby completing the conversion of the digital key.
The calculation formula and the comparison table in the preset conversion rule can be adjusted or replaced according to needs, and the above example about the conversion rule is only used as a kind of implementation manner of the technical solution of the present application, and does not constitute a limitation to the protection scope and other implementation manners of the present application. Other implementations will occur to those skilled in the art without inventive effort given the benefit of this disclosure.
The embodiment provides a data encryption method, which includes generating a position data set according to a preset picture library, then obtaining a color value data set according to the position data set, encrypting data to be sent according to the color value data set to obtain a ciphertext, and finally sending the ciphertext and the position data set to a receiving end. The method dynamically generates the secret key based on the same picture resources respectively owned by the two ends of the receiving party and the receiving party, realizes more safe symmetric encryption, and has the advantages of symmetric encryption and asymmetric encryption.
Fig. 4 is a flowchart of a data decryption method according to an exemplary embodiment of the present application, which is applied to a receiving end, and as shown in fig. 4, the method may include:
at step 410, a ciphertext and a position data set are received.
The position data set can be a data set randomly generated by a sending end, the position data set comprises at least one group of position data, each group of position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier, the picture identifier is used for uniquely determining one picture in a picture library, and the position coordinate corresponding to the picture identifier is used for positioning a pixel point on the picture.
In some embodiments, the data format of the position data set is an array, each set of position data in the position data set is an element in the array, the key Value of the element is a picture identifier, and the Value of the element is also an array, and the array includes one or more point coordinates.
And the ciphertext is obtained by encrypting the data to be sent by the sending end according to the color value data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set.
It should be noted that the picture library preset at the receiving end is the same as the picture library preset at the transmitting end. The process of generating the position data set, generating the color value data set according to the position data set, and encrypting the data to be transmitted according to the color value data set to obtain the ciphertext by the sending end may refer to the embodiments shown in fig. 1 to 3, and is not described herein again.
A color value dataset is obtained from the position dataset, step 420.
Under the condition that the position data set is known and the picture libraries are the same, the receiving end can acquire the color value data set used by the encrypted data of the sending end according to the position data set.
In a specific implementation, the step of obtaining the color value dataset from the position dataset may include:
firstly, acquiring a target picture from a picture library according to a picture identifier;
then, according to the position coordinate corresponding to the picture identification, color value data of a pixel point corresponding to the position coordinate on the target picture is obtained;
further, the sets of color value data corresponding to the plurality of pixel points form a color value dataset. Wherein the order of the color value data in the color value data set coincides with the order of the position coordinates included in the position data set.
And 430, decrypting the ciphertext according to the color value data set.
Firstly, a key required to be used for decryption is generated according to the color value dataset, and the key is the key used by a sending end for data encryption. Specifically, the color value data in the color value data set can be spliced end to obtain the digital key. In some embodiments, if the preset encryption algorithm does not support the digital key, the digital key may be further converted into an alphabetic key according to a preset conversion rule, and the alphabetic key is used for data encryption. The preset conversion rule is a rule with good pre-agreement of both receiving and sending ends.
After the digital key or the letter key is obtained, the received ciphertext can be decrypted by using the digital key or the letter key and a preset encryption algorithm to obtain a plaintext.
The embodiment provides a data encryption and decryption method, which includes generating a position data set according to a preset picture library, then obtaining a color value data set according to the position data set, wherein the color value data set includes color value data of pixel points represented by each group of position data in the position data set, encrypting data to be sent according to the color value data set to obtain a ciphertext, and finally sending the ciphertext and the position data set to a receiving end. In the method, the sending end uses the picture resource consistent with the receiving end as the key source to realize the dynamic generation of the key, and the receiving end obtains the key used by the sending end according to the position data set used by the sending end and the picture resource consistent with the sending end, and the key is used for decrypting the ciphertext, so that the symmetric encryption is realized, and the higher security is realized.
According to the data encryption method provided by the present application, the present application further provides a data encryption apparatus, which can be applied to a data sending end, as shown in fig. 5, the apparatus includes:
a generating module 510, configured to generate a position data set according to a preset picture library, where the picture library includes at least one picture, the position data set includes at least one group of position data, and each group of position data is used to represent a position of at least one pixel point on one picture; an obtaining module 520, configured to obtain a color value dataset according to the location dataset, where the color value dataset includes color value data of a pixel point represented by each set of location data in the location dataset; an encrypting module 530, configured to encrypt data to be sent according to the color value data set to obtain a ciphertext; a sending module 540, configured to send the ciphertext and the position data set to a receiving end.
In some embodiments, each set of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier; the acquisition module includes: the first acquisition unit is used for acquiring a target picture from the picture library according to the picture identifier; and the second acquisition unit is used for acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identifier.
In some embodiments, the encryption module comprises: a generating unit for generating a key from the color value dataset; and the encryption unit is used for encrypting the data to be transmitted by using the secret key and a preset encryption algorithm to obtain a ciphertext.
In some embodiments, the generating unit is specifically configured to: splicing the color value data in the color value data set from beginning to end to obtain a digital key; wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
In some embodiments, the generating unit is further configured to: and converting the digital key into an alphabetic key according to a preset conversion rule.
According to the data decryption method provided by the present application, the present application further provides a data decryption apparatus, which can be applied to a data receiving end, as shown in fig. 6, the apparatus includes:
a receiving module 610, configured to receive a ciphertext and a position data set, where the position data set includes at least one set of position data, and each set of position data is used to represent a position of at least one pixel point on one picture in a preset picture library; the ciphertext is obtained by encrypting data to be sent by a sending end according to a color value data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set; an obtaining module 620, configured to obtain the color value dataset according to the position dataset; and a decryption module 630, configured to decrypt the ciphertext according to the color value dataset.
In some embodiments, each set of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier; the acquisition module includes: the first acquisition unit is used for acquiring a target picture from the picture library according to the picture identifier; and the second acquisition unit is used for acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identifier.
In some embodiments, the decryption module comprises: a generating unit for generating a key from the color value dataset; and the decryption unit is used for decrypting the ciphertext by using the secret key and a preset decryption algorithm.
In some embodiments, the generating unit is specifically configured to: splicing the color value data in the color value data set from beginning to end to obtain a digital key; wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
In some embodiments, the generating unit is further configured to: and converting the digital key into an alphabetic key according to a preset conversion rule.
Fig. 7 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application. As shown in fig. 7, the electronic device may include: a memory 701 for storing program instructions; a processor 702 for calling and executing the program instructions in the memory to implement the above data encryption method and/or implement the above data decryption method.
In this embodiment, the processor and the memory may be connected by a bus or other means. The processor may be a general-purpose processor, such as a central processing unit, a digital signal processor, an application specific integrated circuit, or one or more integrated circuits configured to implement embodiments of the present invention. The memory may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, a hard disk, or a solid state disk.
In a specific implementation, the present invention further provides a computer storage medium, where the computer storage medium may store a computer program, and when at least one processor of the data encryption device and/or the data decryption device executes the computer program, the device for obtaining the user interest level executes some or all of the steps in each embodiment of the data encryption method and/or the data decryption method of the present application. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM).
Those skilled in the art will readily appreciate that the techniques of the embodiments of the present invention may be implemented as software plus a required general purpose hardware platform. Based on such understanding, the technical solutions in the embodiments of the present invention may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The same and similar parts in the various embodiments in this specification may be referred to each other. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the description in the method embodiment.
The above-described embodiments of the present invention should not be construed as limiting the scope of the present invention.

Claims (22)

1. A data encryption method is applied to a sending end, and is characterized in that the method comprises the following steps:
generating a position data set according to a preset picture library, wherein the picture library comprises at least one picture, the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture;
acquiring a color value dataset according to the position dataset, wherein the color value dataset comprises color value data of pixel points represented by each group of position data in the position dataset;
and encrypting the data to be sent according to the color value data set to obtain a ciphertext, and sending the ciphertext and the position data set to a receiving end.
2. The method of claim 1, wherein each set of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the obtaining a color value dataset from a position dataset comprises:
acquiring a target picture from the picture library according to the picture identification;
and acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identification.
3. The method according to claim 1 or 2, wherein encrypting the data to be transmitted according to the color value data set to obtain the ciphertext comprises:
generating a key from the color value dataset;
and encrypting the data to be transmitted by using the secret key and a preset encryption algorithm to obtain a ciphertext.
4. The method of claim 3, wherein generating the key from the color value dataset comprises:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
5. The method of claim 4, wherein the generating a key from the color value dataset further comprises:
and converting the digital key into an alphabetic key according to a preset conversion rule.
6. A data decryption method is applied to a receiving end, and is characterized by comprising the following steps:
receiving a ciphertext and a position data set, wherein the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture in a preset picture library; the ciphertext is obtained by encrypting data to be sent by a sending end according to a color value data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set;
acquiring the color value dataset from the position dataset;
and decrypting the ciphertext according to the color value data set.
7. The method of claim 6, wherein each set of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the obtaining a color value dataset from a position dataset comprises:
acquiring a target picture from the picture library according to the picture identification;
and acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identification.
8. The method of claim 6 or 7, wherein decrypting the ciphertext from the color value dataset comprises:
generating a key from the color value dataset;
and decrypting the ciphertext by using the secret key and a preset decryption algorithm.
9. The method of claim 8, wherein generating the key from the color value dataset comprises:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
10. The method of claim 9, wherein generating the key from the color value dataset further comprises:
and converting the digital key into an alphabetic key according to a preset conversion rule.
11. A data encryption device is applied to a sending end, and is characterized in that the device comprises:
the generating module is used for generating a position data set according to a preset picture library, wherein the picture library comprises at least one picture, the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture;
the acquisition module is used for acquiring a color value dataset according to the position dataset, wherein the color value dataset comprises color value data of pixel points represented by each group of position data in the position dataset;
the encryption module is used for encrypting the data to be sent according to the color value data set to obtain a ciphertext;
and the sending module is used for sending the ciphertext and the position data set to a receiving end.
12. The apparatus according to claim 11, wherein each set of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the acquisition module includes:
the first acquisition unit is used for acquiring a target picture from the picture library according to the picture identifier;
and the second acquisition unit is used for acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identifier.
13. The apparatus of claim 11 or 12, wherein the encryption module comprises:
a generating unit for generating a key from the color value dataset;
and the encryption unit is used for encrypting the data to be transmitted by using the secret key and a preset encryption algorithm to obtain a ciphertext.
14. The apparatus according to claim 13, wherein the generating unit is specifically configured to:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
15. The apparatus of claim 14, wherein the generating unit is further configured to:
and converting the digital key into an alphabetic key according to a preset conversion rule.
16. A data decryption apparatus, applied to a receiving end, the apparatus comprising:
the receiving module is used for receiving the ciphertext and a position data set, wherein the position data set comprises at least one group of position data, and each group of position data is used for representing the position of at least one pixel point on one picture in a preset picture library; the ciphertext is obtained by encrypting data to be sent by a sending end according to a color value data set, wherein the color value data set comprises color value data of pixel points represented by each group of position data in the position data set;
an obtaining module configured to obtain the color value dataset according to the position dataset;
and the decryption module is used for decrypting the ciphertext according to the color value data set.
17. The apparatus of claim 16, wherein each set of the position data comprises a picture identifier and at least one position coordinate corresponding to the picture identifier;
the acquisition module includes:
the first acquisition unit is used for acquiring a target picture from the picture library according to the picture identifier;
and the second acquisition unit is used for acquiring color value data of at least one pixel point corresponding to the at least one position coordinate on the target picture according to the at least one position coordinate corresponding to the picture identifier.
18. The apparatus according to claim 16 or 17, wherein the decryption module comprises:
a generating unit for generating a key from the color value dataset;
and the decryption unit is used for decrypting the ciphertext by using the secret key and a preset decryption algorithm.
19. The apparatus according to claim 18, wherein the generating unit is specifically configured to:
splicing the color value data in the color value data set from beginning to end to obtain a digital key;
wherein an order of the color value data in the color value data set coincides with an order of the position coordinates included in the position data set.
20. The apparatus of claim 19, wherein the generating unit is further configured to:
and converting the digital key into an alphabetic key according to a preset conversion rule.
21. An electronic device, comprising:
a memory for storing program instructions;
a processor for invoking and executing program instructions in the memory to implement the method of any of claims 1-10.
22. A storage medium, characterized in that the storage medium has stored therein a computer program which, when executed by at least one processor of the apparatus of any one of claims 11-15 and/or the apparatus of any one of claims 16-20, performs the method of any one of claims 1-5 and/or any one of claims 6-10.
CN201911373522.5A 2019-12-27 2019-12-27 Data encryption and decryption method and device, electronic equipment and storage medium Active CN111131270B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911373522.5A CN111131270B (en) 2019-12-27 2019-12-27 Data encryption and decryption method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911373522.5A CN111131270B (en) 2019-12-27 2019-12-27 Data encryption and decryption method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111131270A true CN111131270A (en) 2020-05-08
CN111131270B CN111131270B (en) 2021-11-16

Family

ID=70503754

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911373522.5A Active CN111131270B (en) 2019-12-27 2019-12-27 Data encryption and decryption method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111131270B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114884716A (en) * 2022-04-28 2022-08-09 世融能量科技有限公司 Encryption and decryption method, device and medium
CN115051794A (en) * 2022-05-18 2022-09-13 广州瀚信通信科技股份有限公司 Key generation method and information transmission method

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6496599B1 (en) * 1998-04-01 2002-12-17 Autodesk Canada Inc. Facilitating the compositing of video images
CN104468090A (en) * 2014-11-12 2015-03-25 辽宁大学 Chinese character password encoding method based on image pixel coordinates
CN104579637A (en) * 2013-10-28 2015-04-29 华为技术有限公司 Key generation method and device
CN105306440A (en) * 2015-09-19 2016-02-03 杭州电子科技大学 Key generation and distribution method based on graph recognition
CN105453483A (en) * 2013-06-13 2016-03-30 维萨国际服务协会 Image-based key derivation function
CN106993198A (en) * 2017-04-20 2017-07-28 努比亚技术有限公司 Image ciphering method, terminal and computer-readable recording medium
WO2019010421A1 (en) * 2017-07-07 2019-01-10 Ligatti Jay Systems and methods for generating symmetric cryptographic keys
CN109995520A (en) * 2019-03-06 2019-07-09 西北大学 Cipher key transmission methods, image processing platform based on depth convolutional neural networks

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6496599B1 (en) * 1998-04-01 2002-12-17 Autodesk Canada Inc. Facilitating the compositing of video images
CN105453483A (en) * 2013-06-13 2016-03-30 维萨国际服务协会 Image-based key derivation function
CN104579637A (en) * 2013-10-28 2015-04-29 华为技术有限公司 Key generation method and device
CN104468090A (en) * 2014-11-12 2015-03-25 辽宁大学 Chinese character password encoding method based on image pixel coordinates
CN105306440A (en) * 2015-09-19 2016-02-03 杭州电子科技大学 Key generation and distribution method based on graph recognition
CN106993198A (en) * 2017-04-20 2017-07-28 努比亚技术有限公司 Image ciphering method, terminal and computer-readable recording medium
WO2019010421A1 (en) * 2017-07-07 2019-01-10 Ligatti Jay Systems and methods for generating symmetric cryptographic keys
CN109995520A (en) * 2019-03-06 2019-07-09 西北大学 Cipher key transmission methods, image processing platform based on depth convolutional neural networks

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114884716A (en) * 2022-04-28 2022-08-09 世融能量科技有限公司 Encryption and decryption method, device and medium
CN114884716B (en) * 2022-04-28 2024-02-27 世融能量科技有限公司 Encryption and decryption method, device and medium
CN115051794A (en) * 2022-05-18 2022-09-13 广州瀚信通信科技股份有限公司 Key generation method and information transmission method

Also Published As

Publication number Publication date
CN111131270B (en) 2021-11-16

Similar Documents

Publication Publication Date Title
US10880732B2 (en) Authentication of phone caller identity
US11283778B2 (en) Data exchange system, method and device
CN107786331B (en) Data processing method, device, system and computer readable storage medium
CN113162752B (en) Data processing method and device based on hybrid homomorphic encryption
CN109274644A (en) A kind of data processing method, terminal and watermark server
CN109525388B (en) Combined encryption method and system with separated keys
CN109039997B (en) Secret key obtaining method, device and system
CN111131270B (en) Data encryption and decryption method and device, electronic equipment and storage medium
CN111884802B (en) Media stream encryption transmission method, system, terminal and electronic equipment
CN115603907A (en) Method, device, equipment and storage medium for encrypting storage data
CN116662941A (en) Information encryption method, device, computer equipment and storage medium
CN114286131A (en) Transmission method and device for anchor image model file in live broadcast wheat
CN114866312B (en) Shared data determining method and device for protecting data privacy
CN112399027A (en) Picture encryption and decryption method and device, storage medium and electronic equipment
WO2018171302A1 (en) Method and apparatus for use in information processing
CN108985109A (en) A kind of date storage method and device
CN115567263A (en) Data transmission management method, data processing method and device
CN114339282A (en) Method and device for transmitting anchor image picture in live broadcast interaction
CN112637442B (en) Method and device for encrypting circulating images by cloud server and local end
CN104363584B (en) A kind of method, apparatus and terminal of short message Encrypt and Decrypt
CN113672954A (en) Feature extraction method and device and electronic equipment
Stalin et al. Payback of image encryption techniques: a quantitative investigation
CN110691068A (en) Cloud server login system, method and device
CN117156061B (en) Data processing method and device, electronic equipment and storage medium
CN113434845B (en) Business handling method and device, electronic equipment and computer readable storage medium

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