CN111368310B - Data encryption and decryption methods and devices, electronic equipment and storage medium - Google Patents

Data encryption and decryption methods and devices, electronic equipment and storage medium Download PDF

Info

Publication number
CN111368310B
CN111368310B CN201910789841.8A CN201910789841A CN111368310B CN 111368310 B CN111368310 B CN 111368310B CN 201910789841 A CN201910789841 A CN 201910789841A CN 111368310 B CN111368310 B CN 111368310B
Authority
CN
China
Prior art keywords
preset
data
character
determining
encrypted
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910789841.8A
Other languages
Chinese (zh)
Other versions
CN111368310A (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.)
Hangzhou Hikvision System Technology Co Ltd
Original Assignee
Hangzhou Hikvision System Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision System Technology Co Ltd filed Critical Hangzhou Hikvision System Technology Co Ltd
Priority to CN201910789841.8A priority Critical patent/CN111368310B/en
Publication of CN111368310A publication Critical patent/CN111368310A/en
Application granted granted Critical
Publication of CN111368310B publication Critical patent/CN111368310B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Bioethics (AREA)
  • Storage Device Security (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the invention provides a data encryption and decryption method, a device, an electronic device and a storage medium, wherein the data encryption method comprises the following steps: acquiring data to be encrypted; according to a preset gray value setting rule, determining a gray value corresponding to a character contained in the data to be encrypted; determining a color value corresponding to each character contained in the data to be encrypted according to a preset color value setting rule; determining pixel points corresponding to the color values and the gray values corresponding to each character; and generating a target image by using the pixel points according to a preset generation mode, and taking the target image as encryption data corresponding to the data to be encrypted. The image is encrypted to generate an image because of the flooding of personalized images caused by the artistic style, the aesthetic personal, the information explosion and the like of the image and the various styles of the image, so that the concealment of the encrypted data can be improved, and the safety of the encrypted data can be improved.

Description

Data encryption and decryption methods and devices, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a data encryption method, a data decryption method, a data encryption device, a data decryption device, an electronic device, and a storage medium.
Background
With the advent of the big data age, the problem of information security is more and more emphasized, and the requirements of encryption technology for data information are also higher and higher. The basic process of data encryption is to process the original data in plaintext into ciphertext in some encryption mode, so as to ensure the safety of the data.
Common encryption modes can be classified into symmetric encryption modes, such as Data Encryption Standard, international Data Encryption Algorithm, MD5 algorithm, novel elliptic curve algorithm, and the like. The encrypted data obtained by encrypting the data in the current encryption mode is text, and the encrypted data is stored or transmitted in the text mode.
Since the general encryption algorithm has a certain rule from the cryptography point of view, the encrypted ciphertext has a certain rule, a string of characters obtained by encryption is easy to identify, the concealment is poor, and the security of the encrypted data is low.
Disclosure of Invention
The embodiment of the invention aims to provide a data encryption and decryption method, a device, an electronic device and a storage medium, so as to improve the security of encrypted data. The specific technical scheme is as follows:
In a first aspect, an embodiment of the present invention provides a data encryption method, where the method includes:
acquiring data to be encrypted;
determining a gray value corresponding to a character contained in the data to be encrypted according to a preset gray value setting rule;
determining a color value corresponding to each character contained in the data to be encrypted according to a preset color value setting rule;
determining pixel points corresponding to the color values and the gray values corresponding to each character;
and generating a target image by using the pixel points according to a preset generation mode, and taking the target image as encryption data corresponding to the data to be encrypted.
Optionally, the step of determining the gray value corresponding to the character included in the data to be encrypted according to the preset gray value setting rule includes:
determining the type of each character contained in the data to be encrypted;
and determining the gray value corresponding to each character according to the corresponding relation between the preset gray value and the type.
Optionally, the step of determining the color value corresponding to each character included in the data to be encrypted according to a preset color value setting rule includes:
determining the corresponding position of each character contained in the data to be encrypted in a preset three-dimensional coordinate system according to a preset distribution mode;
And determining the color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system.
Optionally, the coordinate value range of the preset three-dimensional coordinate system is (0, 255);
the step of determining the color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system comprises the following steps:
and determining the coordinates of the corresponding position of each character in a preset three-dimensional coordinate system as RGB values corresponding to the character.
Optionally, the step of generating the target image by using the pixel point according to a preset generation mode includes:
acquiring a standby image;
and replacing the pixel points in the standby image by using the pixel points according to a preset replacement mode to generate a target image.
In a second aspect, an embodiment of the present invention provides a data decryption method, where the method includes:
acquiring a target image;
determining target pixel points and corresponding sequences in the target image according to the inverse process of a preset generation mode adopted when the target image is generated;
determining a character corresponding to the target pixel point according to the inverse process of a preset color value setting rule adopted when the target image is generated and the inverse process of a preset gray value setting rule adopted when the target image is generated;
And arranging the corresponding characters according to the sequence corresponding to the target pixel points to obtain decrypted data.
Optionally, the step of determining the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated includes:
determining the type of the character corresponding to each target pixel point according to the corresponding relation between the preset gray value and the type;
and determining the character corresponding to each target pixel point according to the type and the color value of the character corresponding to each target pixel point and the inverse process of a preset color value setting rule adopted when the target image is generated.
Optionally, the step of determining the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset generation mode adopted when the target image is generated includes:
acquiring a preset replacement mode adopted when generating a target image;
and determining target pixel points and corresponding sequences in the target image according to the inverse process of the preset replacement mode.
In a third aspect, an embodiment of the present invention provides a data encryption apparatus, including:
The data to be encrypted acquisition module is used for acquiring data to be encrypted;
the gray value determining module is used for determining gray values corresponding to characters contained in the data to be encrypted according to preset gray value setting rules;
the color value determining module is used for determining a color value corresponding to each character contained in the data to be encrypted according to a preset color value setting rule;
the pixel point determining module is used for determining the pixel points corresponding to the color values and the gray values corresponding to each character;
and the data encryption module is used for generating a target image by using the pixel points according to a preset generation mode and taking the target image as encryption data corresponding to the data to be encrypted.
Optionally, the gray value determining module includes:
a type determining unit configured to determine a type of each character included in the data to be encrypted;
and the gray value determining unit is used for determining the gray value corresponding to each character according to the corresponding relation between the preset gray value and the type.
Optionally, the color value determining module includes:
the position determining unit is used for determining the corresponding position of each character contained in the data to be encrypted in a preset three-dimensional coordinate system according to a preset distribution mode;
And the color value determining unit is used for determining the color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system.
Optionally, the coordinate value range of the preset three-dimensional coordinate system is (0, 255);
the color value determination unit includes:
and the color value determining subunit is used for determining the coordinates of the corresponding position of each character in the preset three-dimensional coordinate system as the RGB value corresponding to the character.
Optionally, the data encryption module includes:
a standby image acquisition unit configured to acquire a standby image;
and the second data encryption unit is used for replacing the pixel points in the standby image by using the pixel points according to a preset replacement mode to generate a target image.
In a fourth aspect, an embodiment of the present invention provides a data decryption apparatus, including:
the target image acquisition module is used for acquiring a target image;
the pixel sequence determining module is used for determining target pixel points and corresponding sequences in the target image according to the inverse process of a preset generation mode adopted when the target image is generated;
the character determining module is used for determining the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated;
And the data decryption module is used for arranging the corresponding characters according to the sequence corresponding to the target pixel point to obtain decrypted data.
Optionally, the character determining module includes:
the character type determining unit is used for determining the type of the character corresponding to each target pixel point according to the corresponding relation between the preset gray value and the type;
and the character determining unit is used for determining the character corresponding to each target pixel point according to the type and the color value of the character corresponding to each target pixel point and the inverse process of the preset color value setting rule adopted when the target image is generated.
Optionally, the pixel point sequence determining module includes:
a replacement mode acquisition unit configured to acquire a preset replacement mode adopted when the target image is generated;
and the second sequence determining unit is used for determining target pixel points and corresponding sequences in the target image according to the reverse process of the preset replacement mode.
In a fifth aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
A memory for storing a computer program;
and the processor is used for realizing any one of the data encryption method steps or any one of the data decryption method steps when executing the program stored in the memory.
In a sixth aspect, an embodiment of the present invention provides a computer readable storage medium, in which a computer program is stored, the computer program implementing any one of the above-mentioned data encryption method steps or any one of the above-mentioned data decryption method steps when executed by a processor.
In the scheme provided by the embodiment of the invention, the electronic equipment can acquire the data to be encrypted, determine the gray value corresponding to the character contained in the data to be encrypted according to the preset gray value setting rule, and determine the color value corresponding to each character contained in the data to be encrypted according to the preset color value setting rule, further determine the color value corresponding to each character and the pixel point corresponding to the gray value, and generate the target image by using the pixel points according to the preset generation mode as the encrypted data corresponding to the data to be encrypted. The image is encrypted to generate an image because of the flooding of personalized images caused by the artistic style, the aesthetic personal, the information explosion and the like of the image and the various styles of the image, so that the concealment of the encrypted data can be improved, and the safety of the encrypted data can be improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of 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 drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a data encryption method according to an embodiment of the present invention;
FIG. 2 is a specific flowchart of step S103 in the embodiment shown in FIG. 1;
FIG. 3 is a specific flowchart of step S105 in the embodiment shown in FIG. 1;
FIG. 4 is a flowchart of a data decryption method according to an embodiment of the present invention;
FIG. 5 is a flowchart showing a step S402 in the embodiment shown in FIG. 4;
fig. 6 is a schematic structural diagram of a data encryption device according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a data decryption device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of another electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In order to improve the security of encrypted data, the embodiment of the invention provides a data encryption method, a data decryption method, a device, an electronic device and a computer readable storage medium.
The following first describes a data encryption method provided by an embodiment of the present invention.
The data encryption method provided by the embodiment of the invention can be applied to any electronic equipment needing to encrypt data, for example, computers, mobile phones, processors and the like, and is not particularly limited. For convenience of description, the following is referred to as an electronic device.
As shown in fig. 1, a data encryption method, the method includes:
s101, obtaining data to be encrypted;
s102, determining a gray value corresponding to a character contained in the data to be encrypted according to a preset gray value setting rule;
S103, determining a color value corresponding to each character contained in the data to be encrypted according to a preset color value setting rule;
s104, determining pixel points corresponding to the color values and the gray values corresponding to each character;
s105, generating a target image by using the pixel point according to a preset generation mode, and taking the target image as encryption data corresponding to the data to be encrypted.
In the scheme provided by the embodiment of the invention, the electronic device can acquire the data to be encrypted, determine the gray value corresponding to the character contained in the data to be encrypted according to the preset gray value setting rule, and determine the color value corresponding to each character contained in the data to be encrypted according to the preset color value setting rule, further determine the color value corresponding to each character and the pixel point corresponding to the gray value, and generate the target image by using the pixel points according to the preset generation mode as the encrypted data corresponding to the data to be encrypted. The image is encrypted to generate an image because of the flooding of personalized images caused by the artistic style, the aesthetic personal, the information explosion and the like of the image and the various styles of the image, so that the concealment of the encrypted data can be improved, and the safety of the encrypted data can be improved.
In the step S101, the electronic device may acquire data to be encrypted, where the data to be encrypted is the data to be encrypted. The data to be encrypted can be data generated or stored by the electronic equipment, or can be data sent by other electronic equipment, which is reasonable. The form of the data to be encrypted may be any type of character, for example, chinese, english, korean, numerals, symbols, etc., and is not particularly limited herein.
After the data to be encrypted is obtained, the electronic device may determine the gray value corresponding to the character included in the data to be encrypted according to the preset gray value setting rule, that is, execute the step S102. In order to facilitate determination of the gray value corresponding to the character included in the data to be encrypted, a gray value setting rule, that is, a preset gray value setting rule, may be preset. The preset gray value setting rule may be determined according to factors such as the type of data to be encrypted, for example, the preset gray value setting rule may be a chinese corresponding gray value 100, a digital corresponding gray value 227, etc.
In one embodiment, the electronic device may determine a type of each character included in the data to be encrypted, and further determine a gray value corresponding to a type of most characters as a gray value corresponding to a character included in the data to be encrypted. For example, the data to be encrypted contains 10 characters, 6 characters are Chinese and 4 characters are numbers, so that the gray value corresponding to the Chinese of the electronic device can be the gray value corresponding to the character contained in the data to be encrypted.
In another embodiment, the preset gray value setting rule may determine the gray value according to a time period, for example, divide a day into a plurality of time periods, where each time period corresponds to one gray value, and then the electronic device may determine the corresponding gray value according to the time period in which the current time is located, and further determine the gray value as the gray value corresponding to the character included in the data to be encrypted.
For example, assuming that a day is divided into 24 time periods from 0 point, which sequentially correspond to the gray values 100-123, if the current time is 9 points and 10 points, the electronic device may determine the gray value 108 corresponding to the current time, and then may determine the gray value 108 corresponding to the character included in the data to be encrypted.
In the step S103, the electronic device may determine a color value corresponding to each character included in the data to be encrypted according to a preset color value setting rule. In order to facilitate determination of the color value corresponding to each character included in the data to be encrypted, a color value setting rule, that is, a preset color value setting rule, may be preset. The preset color value setting rule may be determined according to factors such as the type of data to be encrypted, for example, a color value may be corresponding to each chinese character, and a corresponding color value may be determined according to a character arrangement sequence.
The color value is an RGB value, and the three components in the RGB value are all in the range of 0-255, so that the color value can correspond to 255×255×255= 16581375 characters, and the number of Chinese characters for the most complex Chinese is far from that, so that the problem that the corresponding color value cannot be determined by the characters contained in the data to be encrypted does not occur.
It should be noted that, the execution sequence of the step S102 and the step S103 is not limited, and the step S102 may be executed first and then the step S103 may be executed; step S103 may be executed first, and step S102 may be executed later; it is reasonable that step S102 and step S103 may also be performed simultaneously, and embodiments of the present invention are not limited herein.
After determining the gray value and the color value, the electronic device may execute the step S104, that is, determine the pixel point corresponding to the color value and the gray value corresponding to each character. The pixel point has two characteristics of a color value and a gray value, so that after the two characteristics are determined, the pixel point can be determined.
Furthermore, the electronic device can generate the target image according to a preset generation mode by using the pixel points. In one embodiment, the electronic device may generate the target image including only the pixels according to a certain rule using the pixels. For example, according to the arrangement sequence of characters in the data to be encrypted, arranging the pixel points corresponding to each character to obtain the target image.
In another embodiment, the electronic device may generate the target image according to a certain rule by using the pixel points and other preset pixel points. For example, the number of pixels is 9000, and the electronic device may determine 1000 preset pixels, and further generate a target image with a size of 100×100 using the 10000 pixels.
The target image may be used as encrypted data corresponding to the data to be encrypted. After the encrypted data is obtained, the electronic equipment can store, transmit and the like the encrypted data according to the requirements, the encrypted data is an image, the concealment is high, and the safety of the encrypted data is greatly improved.
As an implementation manner of the embodiment of the present invention, the step of determining the gray value corresponding to the character included in the data to be encrypted according to the preset gray value setting rule may include:
determining the type of each character contained in the data to be encrypted; and determining the gray value corresponding to each character according to the corresponding relation between the preset gray value and the type.
The electronic device may determine a type of each character included in the data to be encrypted, where the type of the character may be a chinese character, an english, a japanese, a number, a symbol, etc., which is not limited herein. Furthermore, the electronic device may search a corresponding relation between a preset gray value and a type, and determine a gray value corresponding to each character. For example, in the preset correspondence between gray values and types, the gray value corresponding to english is 50, and if the character 1 is english, the gray value corresponding to the character 1 is 50.
In one embodiment, the electronic device may store the correspondence between the preset gray value and the type in a table manner, for example, may be as follows:
sequence number Type(s) Gray scale value
1 Type A Gray value g1
2 Type B Gray value g2
3 Type C Gray value g3
n Type N Gray value gn
Based on the above table, if the electronic device determines that the type of the character is type B, it can determine that its corresponding gradation value is a gradation value g2.
It can be seen that, in this embodiment, the electronic device may determine a type of each character included in the data to be encrypted, and further determine, according to a preset correspondence between the gray value and the type, the gray value corresponding to each character. Thus, the electronic device can quickly and accurately determine the gray value corresponding to each character contained in the data to be encrypted.
As shown in fig. 2, the step of determining the color value corresponding to each character included in the data to be encrypted according to the preset color value setting rule may include:
s201, determining the corresponding position of each character contained in the data to be encrypted in a preset three-dimensional coordinate system according to a preset distribution mode;
Since the color value of the pixel point is generally composed of three components, and the positions of coordinate points in the three-dimensional coordinate system are also represented by the three components, the electronic device may previously establish a three-dimensional coordinate system, that is, the above-mentioned preset three-dimensional coordinate system. Therefore, the electronic equipment can determine the corresponding position of each character contained in the data to be encrypted in the preset three-dimensional coordinate system according to the preset distribution mode.
The preset distribution manner may be set according to factors such as encryption requirements, and is not limited herein. For example, the electronic device may determine, in each quadrant, a position corresponding to each character in turn according to an arrangement order of characters included in the data to be encrypted. For another example, the electronic device may group the characters according to the number of characters contained in the data to be encrypted, and the characters in the same group determine the corresponding positions in the same quadrant.
S202, determining a color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system.
After determining the corresponding position of each character in the preset three-dimensional coordinate system, the electronic device can determine the color value corresponding to each character based on the corresponding position of each character in the preset three-dimensional coordinate system. In one embodiment, the coordinates of the position corresponding to each character in the preset three-dimensional coordinate system may be mathematically calculated at a preset value, and the obtained value is determined as the color value corresponding to the character.
For example, the electronic device determines that the coordinates of the position corresponding to the character 1 in the preset three-dimensional coordinate system are (155, 20, 254), and may determine that the value obtained by subtracting 5 from each coordinate value of the coordinates is the color value corresponding to the character 1, that is, (155-5, 20-5, 254-5) = (150, 15, 249).
It can be seen that, in this embodiment, the electronic device may determine, according to a preset distribution manner, a corresponding position of each character included in the data to be encrypted in a preset three-dimensional coordinate system, and determine, based on the corresponding position of each character in the preset three-dimensional coordinate system, a color value corresponding to each character. Since the coordinate values in the three-dimensional coordinate system have the same characteristics as the color values of the pixel points in the image, and the number of the coordinate values is enough, the color values corresponding to each character can be determined based on the corresponding position of each character in the preset three-dimensional coordinate system, so that the data encryption requirement can be met, and the calculated amount is small.
As an implementation manner of the embodiment of the present invention, the coordinate value range of the preset three-dimensional coordinate system may be (0, 255).
Since the color values of the pixel points are generally expressed by RGB values, the coordinate value range of the preset three-dimensional coordinate system may be (0, 255).
Correspondingly, the step of determining the color value corresponding to each character based on the corresponding position of each character in the preset three-dimensional coordinate system may include:
And determining the coordinates of the corresponding position of each character in a preset three-dimensional coordinate system as RGB values corresponding to the character.
Under the condition that the coordinate value range of the preset three-dimensional coordinate system is (0, 255), the coordinate of any position in the preset three-dimensional coordinate system can be used as a color value conforming to the image characteristic, so that after the electronic equipment determines the coordinate of the corresponding position of each character in the preset three-dimensional coordinate system, which is contained in the data to be encrypted, the coordinate of the corresponding position of each character in the preset three-dimensional coordinate system can be determined as the RGB value corresponding to the character.
For example, the electronic device determines that the coordinates of the corresponding position of the character 2 in the preset three-dimensional coordinate system are (0, 125, 89), and then the electronic device may determine that the RGB value corresponding to the character 2 is (0, 125, 89).
It can be seen that, in this embodiment, in the case where the coordinate value range of the preset three-dimensional coordinate system is (0, 255), the electronic device may determine the coordinate of the corresponding position of each character in the preset three-dimensional coordinate system as the RGB value corresponding to the character. In this way, the amount of computation can be further reduced to quickly determine the color value corresponding to each character contained in the data to be encrypted.
As an implementation manner of the embodiment of the present invention, the step of generating the target image by using the pixel point according to a preset generation manner may include:
and arranging the pixel points according to a preset arrangement mode to generate a target image.
After the electronic device determines the pixel points corresponding to the color value and the gray value corresponding to each character contained in the data to be encrypted, the pixel points can be arranged according to a preset arrangement mode, so that a target image is generated.
In one embodiment, the electronic device may set the size of the target image according to the number of characters included in the data to be encrypted, and further arrange pixels corresponding to each character from left to right according to the arrangement sequence of the characters included in the data to be encrypted, so as to obtain the target image.
For example, assuming that the number of characters included in the data to be encrypted is 400, the electronic device may set the size of the target image to 20×20, and further arrange the pixels corresponding to each character from left to right in the arrangement order of the 400 characters, the pixels corresponding to the first 20 characters form the first row of the target image, the pixels corresponding to the next 20 characters form the second row of the target image, and so on, the pixels corresponding to the last 20 characters form the last row of the target image.
In another embodiment, the electronic device may set the size of the target image according to the number of characters included in the data to be encrypted, and arrange the pixel points corresponding to each character according to the mapping relationship between the characters included in the data to be encrypted and the positions in the target image, so as to obtain the target image.
For example, assuming that the number of characters included in the data to be encrypted is 400, the electronic device may set the size of the target image to 20×20, and the mapping relationship between the characters and the positions in the target image is that the characters 1 correspond to the tenth row of the fifth position, and then the electronic device may determine that the pixel points corresponding to the characters 1 are located in the tenth row of the fifth position in the target image, and determine the positions of the pixel points corresponding to all the characters according to this manner, so as to obtain the target image.
In this embodiment, the electronic device may arrange the pixel points corresponding to each character included in the data to be encrypted according to a preset arrangement manner, so as to generate the target image. The preset arrangement mode can be set according to actual needs, can be changed at will, and further improves the safety of encrypted data.
As shown in fig. 3, the step of generating the target image by using the pixel point according to the preset generation manner may include:
S301, acquiring a standby image;
the electronic device may acquire an image as a standby image, where the standby image may be any image, for example, an image stored locally in the electronic device may be an image acquired by the electronic device from another device, and if the electronic device has an image acquisition function, it may also be an image acquired by the electronic device, which is reasonable.
The size, format, content, etc. of the above-mentioned standby image are not particularly limited herein.
S302, replacing the pixel points in the standby image by the pixel points according to a preset replacement mode, and generating a target image.
After the electronic device obtains the standby image, the pixel point in the standby image can be replaced by the pixel point corresponding to each character contained in the data to be encrypted according to a preset replacement mode, so that the target image is obtained. The preset replacing mode can be set according to factors such as encryption requirements, the number of pixel points corresponding to each character contained in the data to be encrypted, and the like, and is not limited in detail herein.
As an implementation manner, the electronic device may preset a correspondence between each character included in the data to be encrypted and pixels in the standby image, where the pixels in the standby image are pixels to be replaced. Further, after the electronic device determines the pixel point corresponding to each character included in the data to be encrypted, the electronic device can replace the corresponding pixel point to be replaced with the pixel point corresponding to the character based on the corresponding relation.
In order to make the target image more hidden, the number of pixel points included in the spare image can be far more than the number of characters included in the data to be encrypted, so that the obtained target image is not very different from the spare image or even is very difficult to find the difference between the two images in the view of human eyes, and the safety of the encrypted data can be improved.
It can be seen that, in this embodiment, the electronic device may acquire the standby image, replace the pixel point in the standby image with the pixel point corresponding to each character included in the data to be encrypted according to the preset replacement mode, and generate the target image. Thus, the target image can be further hidden, and the security of the encrypted data can be further improved.
Compared with the data encryption method, the embodiment of the invention also provides a data decryption method. The following describes a data decryption method provided by the embodiment of the invention.
The data decryption method provided by the embodiment of the invention can be applied to any electronic equipment needing to decrypt data, for example, a computer, a mobile phone, a processor and the like, and is not particularly limited. For convenience of description, the following is referred to as an electronic device. The electronic device may be the same device as the electronic device executing the data encryption method, or may be a different device.
As shown in fig. 4, a data decryption method, the method includes:
s401, acquiring a target image;
s402, determining target pixel points and corresponding sequences in the target image according to the inverse process of a preset generation mode adopted when the target image is generated;
s403, determining the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated;
s404, arranging the corresponding characters according to the sequence corresponding to the target pixel point to obtain decrypted data.
In the scheme provided by the embodiment of the invention, the electronic device can acquire the target image, determine the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset generation mode adopted when the target image is generated, determine the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated, and further arrange the corresponding characters according to the sequence corresponding to the target pixel point to obtain decrypted data. The decryption method can decrypt the obtained target image processed by the data encryption method provided by the embodiment.
In the above step S401, the electronic apparatus may first acquire a target image. The target image is the encrypted data which needs to be decrypted.
The target image is generated according to a preset generation mode by utilizing the pixel points corresponding to the characters contained in the data to be encrypted. Therefore, the electronic device can determine the target pixel points and the corresponding sequence in the target image according to the reverse process of the preset generation mode. The target pixel points are the corresponding pixel points of the characters contained in the data to be encrypted, and the corresponding sequence of the target pixel points is the sequence of the corresponding pixel points of the characters contained in the data to be encrypted, namely the arrangement sequence of the characters contained in the data to be encrypted.
The inverse process of the preset generation mode can be preset in the electronic device so as to process the acquired target image. The preset generation mode can also be obtained from the electronic device for generating the target image or other devices storing the preset generation mode, and then the reverse process of the preset generation mode is determined, which is reasonable.
For example, the characters included in the data to be encrypted are character a, character b, character c and character d, and the corresponding pixels are pixel 1-pixel 4, and the 4 pixels generate the target image according to the arrangement sequence from left to right. The electronic device may determine that the target pixel in the target image is 1-4 pixels, and the order of the 4 pixels is 1-4 from left to right, which means that the arrangement order of the characters corresponding to the 4 pixels in the data to be encrypted is 1-4.
In the step S403, since the gray value and the color value of the target pixel point in the target image are determined according to the preset gray value setting rule and the preset color value setting rule when the data is encrypted, respectively, the electronic device may determine the character corresponding to the target pixel point according to the inverse of the preset color value setting rule and the inverse of the preset gray value setting rule.
The inverse process of the preset gray value setting rule and the preset color value setting rule may be preset in the electronic device, so as to process the obtained target image. The preset gray value setting rule and the preset color value setting rule may be obtained from an electronic device for generating the target image or other devices storing the preset gray value setting rule and the preset color value setting rule, so as to determine the inverse process, which is reasonable.
For example, the preset gray value setting rule is that the corresponding gray value of the Chinese character is 100, the color value corresponding to the character 'i' is (12, 56, 217), and if the gray value of the target pixel point is 100, the color value is (12, 56, 217), the electronic device can use the corresponding character as the Chinese character 'i'.
After determining the characters and the sequence corresponding to the target pixel, the electronic device may execute the step S404, that is, arrange the corresponding characters according to the sequence corresponding to the target pixel, so as to obtain decrypted data.
For example, the electronic device determines that the characters corresponding to the target pixel 11-target pixel 16 are a, 1, C, f, 9, and #, respectively, and the order corresponding to the target pixel 11-target pixel 16 is 6, 1, 2, 5, 4, and 3, and then the electronic device may determine that the decrypted data is 1c#9fa.
As an implementation manner of the embodiment of the present invention, the step of determining the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated may include:
determining the type of the character corresponding to each target pixel point according to the corresponding relation between the preset gray value and the type; and determining the character corresponding to each target pixel point according to the type and the color value of the character corresponding to each target pixel point and the inverse process of a preset color value setting rule adopted when the target image is generated.
When the data are encrypted to obtain the target image, if the gray value corresponding to each character is determined according to the corresponding relation between the preset gray value and the type, the electronic equipment can determine the type of the character corresponding to each target pixel point according to the corresponding relation between the preset gray value and the type when decrypting the data.
For example, if the corresponding relationship between the preset gray value and the type is the english corresponding gray value 55, the electronic device may determine that the type of the character corresponding to the target pixel is english if the gray value of the target pixel is 55.
Furthermore, the electronic device can determine the character corresponding to each target pixel according to the type and the color value of the character corresponding to each target pixel and the inverse process of the preset color value setting rule. After the type of the character corresponding to each target pixel point is determined, the color value of the target pixel point can be determined from the target image, and the color value of the target pixel point is obtained according to the character in the data to be encrypted and the preset color value setting rule, so that the electronic equipment can determine the character corresponding to each target pixel point according to the inverse process of the preset color value setting rule.
It can be seen that, in this embodiment, the electronic device may determine, according to the corresponding relationship between the preset gray value and the type, the type of the character corresponding to each target pixel, and determine, according to the type and the color value of the character corresponding to each target pixel, the character corresponding to each target pixel according to the inverse process of the preset color value setting rule adopted when generating the target image. It can be ensured that the correct decrypted data is obtained.
As shown in fig. 5, the step of determining the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset generation mode adopted when generating the target image may include:
s501, acquiring a preset arrangement mode adopted when generating a target image;
in order to accurately decrypt the target image, the electronic device may acquire a preset arrangement mode adopted when the target image is generated by arranging pixel points corresponding to characters in the data to be encrypted according to the preset arrangement mode. The preset arrangement mode is adopted when the pixel points corresponding to the characters contained in the data to be encrypted generate the target image.
S502, determining all pixel points in the target image as target pixel points;
in this embodiment, since the pixels in the target image are all pixels corresponding to the character included in the data to be encrypted, the electronic device may determine that all the pixels in the target image are target pixels.
S503, determining the sequence corresponding to the target pixel point according to the inverse process of the preset arrangement mode.
Furthermore, according to the inverse process of the preset arrangement mode, the electronic equipment can determine the sequence corresponding to the target pixel points. For example, when the target image is generated, the size of the target image is set according to the number of characters contained in the data to be encrypted, and the pixel points corresponding to each character are arranged from left to right according to the arrangement sequence of the characters contained in the data to be encrypted to obtain the target image, so that the electronic device can determine that the sequence corresponding to the target pixel points is from left to right and sequentially corresponds to the sequence 1 to m, and m is the number of the target pixel points.
In this embodiment, the electronic device may acquire a preset arrangement mode adopted when generating the target image, determine all the pixels in the target image as target pixels, and further determine the sequence corresponding to the target pixels according to the inverse process of the preset arrangement mode. Therefore, the sequence corresponding to the target pixel points can be accurately determined under the condition that the target image is generated by arranging the pixel points corresponding to the characters in the data to be encrypted according to a preset arrangement mode, and the data decryption is accurately ensured.
As an implementation manner of the embodiment of the present invention, the step of determining the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset generation manner adopted when the target image is generated may include:
acquiring a preset replacement mode adopted when generating a target image; and determining target pixel points and corresponding sequences in the target image according to the inverse process of the preset replacement mode.
In the case that the target image is generated by replacing the pixel points in the standby image with the pixel points corresponding to the characters in the data to be encrypted according to the preset replacement mode, in order to accurately decrypt the data, the electronic device may acquire the preset replacement mode adopted when the target image is generated.
Furthermore, the electronic device may determine the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset replacement mode. For example, the target image is generated by replacing pixels in the standby image with pixels corresponding to characters based on the correspondence between each character contained in the data to be encrypted and the pixels in the standby image. The electronic device may determine the target pixel point and the corresponding order in the target image according to the correspondence between each character included in the data to be encrypted and the pixel point in the standby image.
It can be seen that, in this embodiment, the electronic device may acquire a preset replacement mode adopted when generating the target image, and determine the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset replacement mode. Therefore, under the condition that the target image is generated by replacing the pixel points in the standby image with the pixel points corresponding to the characters in the data to be encrypted according to the preset replacement mode, the sequence corresponding to the target pixel points can be accurately determined, and the data decryption can be accurately performed.
Corresponding to the data encryption method, the embodiment of the invention also provides a data encryption device. The following describes a data encryption device provided in an embodiment of the present invention.
As shown in fig. 6, a data encryption apparatus, the apparatus comprising:
a data to be encrypted obtaining module 610, configured to obtain data to be encrypted;
the gray value determining module 620 is configured to determine a gray value corresponding to a character included in the data to be encrypted according to a preset gray value setting rule;
the color value determining module 630 is configured to determine a color value corresponding to each character included in the data to be encrypted according to a preset color value setting rule;
The pixel point determining module 640 is configured to determine a pixel point corresponding to a color value and a gray value corresponding to each character;
the data encryption module 650 is configured to generate, according to a preset generation manner, a target image as encrypted data corresponding to the data to be encrypted by using the pixel point.
In the scheme provided by the embodiment of the invention, the electronic device can acquire the data to be encrypted, determine the gray value corresponding to the character contained in the data to be encrypted according to the preset gray value setting rule, and determine the color value corresponding to each character contained in the data to be encrypted according to the preset color value setting rule, further determine the color value corresponding to each character and the pixel point corresponding to the gray value, and generate the target image by using the pixel points according to the preset generation mode as the encrypted data corresponding to the data to be encrypted. The image is encrypted to generate an image because of the flooding of personalized images caused by the artistic style, the aesthetic personal, the information explosion and the like of the image and the various styles of the image, so that the concealment of the encrypted data can be improved, and the safety of the encrypted data can be improved.
As an implementation manner of the embodiment of the present invention, the above gray value determining module 620 may include:
A type determining unit (not shown in fig. 6) for determining a type of each character contained in the data to be encrypted;
a gray value determining unit (not shown in fig. 6) for determining a gray value corresponding to each character according to a preset correspondence between gray values and types.
As an implementation manner of the embodiment of the present invention, the above-mentioned color value determining module 630 may include:
a position determining unit (not shown in fig. 6) configured to determine, according to a preset distribution manner, a corresponding position of each character included in the data to be encrypted in a preset three-dimensional coordinate system;
a color value determining unit (not shown in fig. 6) for determining a color value corresponding to each character based on a position corresponding to each character in a preset three-dimensional coordinate system.
As an implementation manner of the embodiment of the present invention, the coordinate value range of the preset three-dimensional coordinate system may be (0, 255);
the above-described color value determination unit may include:
a color value determining subunit (not shown in fig. 6) configured to determine, as an RGB value corresponding to the character, coordinates of a position corresponding to the character in a preset three-dimensional coordinate system.
As an implementation manner of the embodiment of the present invention, the data encryption module 650 may include:
A first data encryption unit (not shown in fig. 6) configured to arrange the pixel points according to a preset arrangement manner, and generate a target image.
As an implementation manner of the embodiment of the present invention, the data encryption module 650 may include:
a standby image acquisition unit (not shown in fig. 6) for acquiring a standby image;
and a second data encryption unit (not shown in fig. 6) for replacing the pixels in the standby image with the pixels according to a preset replacement manner to generate a target image.
Corresponding to the data decryption method, the embodiment of the invention also provides a data decryption device. The following describes a data decryption device provided in an embodiment of the present invention.
As shown in fig. 7, a data decryption apparatus, the apparatus comprising:
a target image acquisition module 710 for acquiring a target image;
the pixel sequence determining module 720 is configured to determine a target pixel and a corresponding sequence in the target image according to an inverse process of a preset generation mode adopted when the target image is generated;
the character determining module 730 is configured to determine a character corresponding to the target pixel according to an inverse process of a preset color value setting rule adopted when the target image is generated and an inverse process of a preset gray value setting rule adopted when the target image is generated;
And the data decryption module 740 is configured to arrange the corresponding characters according to the sequence corresponding to the target pixel point, so as to obtain decrypted data.
In the scheme provided by the embodiment of the invention, the electronic device can acquire the target image, determine the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset generation mode adopted when the target image is generated, determine the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated, and further arrange the corresponding characters according to the sequence corresponding to the target pixel point to obtain decrypted data. The decryption method can decrypt the obtained target image processed by the data encryption method provided by the embodiment.
As an implementation manner of the embodiment of the present invention, the character determining module 730 may include:
a character type determining unit (not shown in fig. 7) configured to determine a type of a character corresponding to each of the target pixel points according to a preset correspondence between gray values and types;
and a character determining unit (not shown in fig. 7) configured to determine, according to the type and the color value of the character corresponding to each target pixel, the character corresponding to each target pixel according to an inverse process of a preset color value setting rule adopted when generating the target image.
As an implementation manner of the embodiment of the present invention, the above pixel point sequence determining module 720 may include:
an arrangement pattern acquisition unit (not shown in fig. 7) for acquiring a preset arrangement pattern employed when generating the target image;
a target pixel point determining unit (not shown in fig. 7) configured to determine all pixel points in the target image as target pixel points;
a first order determining unit (not shown in fig. 7) configured to determine an order corresponding to the target pixel points according to an inverse process of the preset arrangement mode.
As an implementation manner of the embodiment of the present invention, the pixel point sequence determining module 730 may include:
an alternative-mode obtaining unit (not shown in fig. 7) for obtaining a preset alternative mode employed when generating the target image;
a second order determining unit (not shown in fig. 7) for determining the target pixel point and the corresponding order in the target image according to the inverse process of the preset alternative mode.
The embodiment of the present invention further provides an electronic device, as shown in fig. 8, where the electronic device may include a processor 801, a communication interface 802, a memory 803, and a communication bus 804, where the processor 801, the communication interface 802, and the memory 803 complete communication with each other through the communication bus 804,
A memory 803 for storing a computer program;
the processor 801 is configured to implement the data encryption method according to any one of the above embodiments when executing the program stored in the memory 803.
In the scheme provided by the embodiment of the invention, the electronic device can acquire the data to be encrypted, determine the gray value corresponding to the character contained in the data to be encrypted according to the preset gray value setting rule, and determine the color value corresponding to each character contained in the data to be encrypted according to the preset color value setting rule, further determine the color value corresponding to each character and the pixel point corresponding to the gray value, and generate the target image by using the pixel points according to the preset generation mode as the encrypted data corresponding to the data to be encrypted. The image is encrypted to generate an image because of the flooding of personalized images caused by the artistic style, the aesthetic personal, the information explosion and the like of the image and the various styles of the image, so that the concealment of the encrypted data can be improved, and the safety of the encrypted data can be improved.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
The embodiment of the present invention further provides an electronic device, as shown in fig. 9, where the electronic device may include a processor 901, a communication interface 902, a memory 903, and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 perform communication with each other through the communication bus 904,
A memory 903 for storing a computer program;
the processor 901 is configured to implement the data decryption method according to any one of the above embodiments when executing the program stored in the memory 903.
In the scheme provided by the embodiment of the invention, the electronic device can acquire the target image, determine the target pixel point and the corresponding sequence in the target image according to the inverse process of the preset generation mode adopted when the target image is generated, determine the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated, and further arrange the corresponding characters according to the sequence corresponding to the target pixel point to obtain decrypted data. The decryption method can decrypt the obtained target image processed by the data encryption method provided by the embodiment.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and the computer program realizes the data encryption method according to any one of the embodiments when being executed by a processor.
In the scheme provided by the embodiment of the invention, when the computer program is executed by the processor, the data to be encrypted can be obtained, the gray value corresponding to the character contained in the data to be encrypted is determined according to the preset gray value setting rule, the color value corresponding to each character contained in the data to be encrypted is determined according to the preset color value setting rule, and then the color value corresponding to each character and the pixel point corresponding to the gray value are determined, and the target image is generated by using the pixel points according to the preset generation mode to serve as the encrypted data corresponding to the data to be encrypted. The image is encrypted to generate an image because of the flooding of personalized images caused by the artistic style, the aesthetic personal, the information explosion and the like of the image and the various styles of the image, so that the concealment of the encrypted data can be improved, and the safety of the encrypted data can be improved.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and the computer program realizes the data decryption method according to any embodiment when being executed by a processor.
In the scheme provided by the embodiment of the invention, when the computer program is executed by the processor, the target image can be acquired, the target pixel points in the target image and the corresponding sequence are determined according to the inverse process of the preset generation mode adopted when the target image is generated, the characters corresponding to the target pixel points are determined according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated, and further, the corresponding characters are arranged according to the sequence corresponding to the target pixel points, so that decrypted data are obtained. The decryption method can decrypt the obtained target image processed by the data encryption method provided by the embodiment.
It should be noted that, for the apparatus, the electronic device, and the computer-readable storage medium embodiments described above, since they are substantially similar to the method embodiments, the description is relatively simple, and references to the parts descriptions of the method embodiments are only needed.
It is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are referred to each other, and each embodiment mainly describes differences from other embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (14)

1. A method of encrypting data, the method comprising:
acquiring data to be encrypted;
determining a gray value corresponding to a character contained in the data to be encrypted according to a preset gray value setting rule;
determining a color value corresponding to each character contained in the data to be encrypted according to a preset color value setting rule;
determining pixel points corresponding to the color values and the gray values corresponding to each character;
and acquiring a standby image, replacing the pixel points in the standby image according to a preset replacement mode by utilizing the pixel points and the corresponding relation between each character contained in the preset data to be encrypted and the pixel points in the standby image, and generating a target image as encrypted data corresponding to the data to be encrypted.
2. The method of claim 1, wherein the step of determining the gray value corresponding to the character included in the data to be encrypted according to the preset gray value setting rule includes:
determining the type of each character contained in the data to be encrypted;
and determining the gray value corresponding to each character according to the corresponding relation between the preset gray value and the type.
3. The method of claim 1, wherein the step of determining a color value corresponding to each character included in the data to be encrypted according to a preset color value setting rule includes:
Determining the corresponding position of each character contained in the data to be encrypted in a preset three-dimensional coordinate system according to a preset distribution mode;
and determining the color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system.
4. A method according to claim 3, wherein the coordinate value range of the preset three-dimensional coordinate system is (0, 255);
the step of determining the color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system comprises the following steps:
and determining the coordinates of the corresponding position of each character in a preset three-dimensional coordinate system as RGB values corresponding to the character.
5. A method of decrypting data, the method comprising:
acquiring a target image;
acquiring a preset replacement mode adopted when generating a target image; determining a target pixel point and a corresponding sequence in the target image according to the inverse process of the preset replacement mode and the corresponding relation between each character contained in the preset data to be encrypted and the pixel point in the standby image;
determining a character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated;
And arranging the corresponding characters according to the sequence corresponding to the target pixel points to obtain decrypted data.
6. The method of claim 5, wherein the step of determining the character corresponding to the target pixel point according to an inverse of a preset color value setting rule used in generating the target image and an inverse of a preset gray value setting rule used in generating the target image comprises:
determining the type of the character corresponding to each target pixel point according to the corresponding relation between the preset gray value and the type;
and determining the character corresponding to each target pixel point according to the type and the color value of the character corresponding to each target pixel point and the inverse process of a preset color value setting rule adopted when the target image is generated.
7. A data encryption device, the device comprising:
the data to be encrypted acquisition module is used for acquiring data to be encrypted;
the gray value determining module is used for determining gray values corresponding to characters contained in the data to be encrypted according to preset gray value setting rules;
the color value determining module is used for determining a color value corresponding to each character contained in the data to be encrypted according to a preset color value setting rule;
The pixel point determining module is used for determining pixel points corresponding to the color values and the gray values corresponding to each character;
the data encryption module is used for acquiring a standby image, replacing the pixel points in the standby image according to a preset replacement mode by utilizing the pixel points and the corresponding relation between each character contained in the preset data to be encrypted and the pixel points in the standby image, and generating a target image as encrypted data corresponding to the data to be encrypted.
8. The apparatus of claim 7, wherein the gray value determination module comprises:
a type determining unit configured to determine a type of each character included in the data to be encrypted;
and the gray value determining unit is used for determining the gray value corresponding to each character according to the corresponding relation between the preset gray value and the type.
9. The apparatus of claim 7, wherein the color value determination module comprises:
the position determining unit is used for determining the corresponding position of each character contained in the data to be encrypted in a preset three-dimensional coordinate system according to a preset distribution mode;
and the color value determining unit is used for determining the color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system.
10. The apparatus of claim 9, wherein the coordinate value range of the preset three-dimensional coordinate system is (0, 255);
the color value determination unit includes:
and the color value determining subunit is used for determining the coordinates of the corresponding position of each character in the preset three-dimensional coordinate system as the RGB value corresponding to the character.
11. A data decryption apparatus, the apparatus comprising:
the target image acquisition module is used for acquiring a target image;
the pixel sequence determining module is used for acquiring a preset replacement mode adopted when the target image is generated; determining a target pixel point and a corresponding sequence in the target image according to the inverse process of the preset replacement mode and the corresponding relation between each character contained in the preset data to be encrypted and the pixel point in the standby image;
the character determining module is used for determining the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule adopted when the target image is generated and the inverse process of the preset gray value setting rule adopted when the target image is generated;
and the data decryption module is used for arranging the corresponding characters according to the sequence corresponding to the target pixel point to obtain decrypted data.
12. The apparatus of claim 11, wherein the character determination module comprises:
the character type determining unit is used for determining the type of the character corresponding to each target pixel point according to the corresponding relation between the preset gray value and the type;
and the character determining unit is used for determining the character corresponding to each target pixel point according to the type and the color value of the character corresponding to each target pixel point and the inverse process of the preset color value setting rule adopted when the target image is generated.
13. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 or 5-6 when executing a program stored on a memory.
14. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-4 or 5-6.
CN201910789841.8A 2019-08-26 2019-08-26 Data encryption and decryption methods and devices, electronic equipment and storage medium Active CN111368310B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910789841.8A CN111368310B (en) 2019-08-26 2019-08-26 Data encryption and decryption methods and devices, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910789841.8A CN111368310B (en) 2019-08-26 2019-08-26 Data encryption and decryption methods and devices, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111368310A CN111368310A (en) 2020-07-03
CN111368310B true CN111368310B (en) 2023-05-02

Family

ID=71208058

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910789841.8A Active CN111368310B (en) 2019-08-26 2019-08-26 Data encryption and decryption methods and devices, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111368310B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103220551A (en) * 2013-03-12 2013-07-24 重庆市科学技术研究院 Digital resource encryption and decryption system and method based on image processing

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008146392A1 (en) * 2007-05-31 2008-12-04 Pfu Limited Electronic document encryption system, decoding system, program, and method
CN103246830B (en) * 2013-04-28 2016-04-13 小米科技有限责任公司 The cipher processing method of client script and device and decipher processing method and device
CN106330976B (en) * 2016-11-03 2020-01-03 武汉斗鱼网络科技有限公司 Information encryption and decryption method and device
CN109118551A (en) * 2017-06-22 2019-01-01 西安中兴新软件有限责任公司 A kind of image processing method, terminal and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103220551A (en) * 2013-03-12 2013-07-24 重庆市科学技术研究院 Digital resource encryption and decryption system and method based on image processing

Also Published As

Publication number Publication date
CN111368310A (en) 2020-07-03

Similar Documents

Publication Publication Date Title
CN107819569B (en) The encryption method and terminal device of log-on message
CN107610191B (en) Color image encryption method and device
CN109905227B (en) System and method for multi-value packing scheme for homomorphic encryption
CN110569227B (en) Model parameter determination method and device and electronic equipment
CN110555525B (en) Model parameter determination method and device and electronic equipment
US20200175178A1 (en) Encrypted data exchange
CN110580409B (en) Model parameter determining method and device and electronic equipment
CN111192352B (en) Map rendering method, map rendering device, computer equipment and storage medium
CN112054896B (en) White box encryption method, white box encryption device, terminal and storage medium
CN112633146B (en) Multi-pose face gender detection training optimization method, device and related equipment
CN111832031A (en) Family file processing method and device, computer equipment and storage medium
CN110232284B (en) Image encryption method and device
JP4189828B1 (en) Pairing calculation device, pairing calculation method, and pairing calculation program
CN114338022A (en) Image encryption method, system, device and computer readable storage medium
CN107977581A (en) Data processing method, device and computer-readable recording medium
CN111368310B (en) Data encryption and decryption methods and devices, electronic equipment and storage medium
KR102239588B1 (en) Image processing method and apparatus
CN110611568B (en) Dynamic encryption and decryption method, device and equipment based on multiple encryption and decryption algorithms
CN113810169A (en) Homomorphic encryption device and ciphertext arithmetic method thereof
CN109739553B (en) Parameter configuration method, device, terminal and storage medium
US9553723B2 (en) Multi-dimensional encryption
CN116132065A (en) Key determination method, device, computer equipment and storage medium
CN114338024B (en) Image decryption method, system, device and computer readable storage medium
CN113240045B (en) Data dimension reduction method and device and related equipment
CN109359226A (en) A kind of data capture method and relevant apparatus

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