CN111368310A - 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
CN111368310A
CN111368310A CN201910789841.8A CN201910789841A CN111368310A CN 111368310 A CN111368310 A CN 111368310A CN 201910789841 A CN201910789841 A CN 201910789841A CN 111368310 A CN111368310 A CN 111368310A
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.)
Granted
Application number
CN201910789841.8A
Other languages
Chinese (zh)
Other versions
CN111368310B (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)
  • Image Processing (AREA)
  • Storage Device Security (AREA)

Abstract

The embodiment of the invention provides a data encryption method, a data decryption method, a data encryption device, an electronic device and a storage medium, wherein the data encryption method comprises the following steps: 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 color values and gray values corresponding to each character; and generating a target image as the encrypted data corresponding to the data to be encrypted by utilizing the pixel points according to a preset generation mode. Due to the fact that personalized images are abused due to reasons such as artistic styles, personal aesthetics and information explosion of the images, and the styles of the images are various, the data are encrypted to generate one image, the concealment of encrypted data can be improved, and the safety of the encrypted data is improved.

Description

Data encryption and decryption method and device, 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 and apparatus, a data decryption method and apparatus, an electronic device, and a storage medium.
Background
With the advent of the big data era, the problem of information security is more and more emphasized, and the requirements of encryption technology for data information are higher and higher. The basic process of data encryption is to process the original plaintext data into ciphertext according to a certain encryption mode, thereby ensuring the security of the data.
Common Encryption methods can be classified into symmetric Encryption methods, for example, Data Encryption Standard, International Data Encryption Algorithm, MD5 Algorithm, new elliptic curve Algorithm, and the like. The encrypted data obtained by encrypting the data in the current encryption mode are texts, and the encrypted data are stored or transmitted in the text mode.
In terms of cryptography, a general encryption algorithm has a certain rule, so that a ciphertext obtained by encryption has a certain rule, a string of characters obtained by encryption is easy to identify, and the security of encrypted data is low due to poor concealment.
Disclosure of Invention
Embodiments of the present invention provide a data encryption method, a data decryption method, a data encryption device, an electronic device, and a storage medium, so as to improve 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 value and the gray value corresponding to each character;
and generating a target image as the encrypted data corresponding to the data to be encrypted by using the pixel points according to a preset generation mode.
Optionally, the step of determining the gray value corresponding to the character included in the data to be encrypted according to a 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 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 a 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 a color value corresponding to each character based on a corresponding position of each character in a preset three-dimensional coordinate system includes:
and determining the coordinates of the corresponding position of each character in a preset three-dimensional coordinate system as the RGB value corresponding to the character.
Optionally, the step of generating the target image by using the pixel points according to a preset generation manner 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 an 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 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 arranging the corresponding characters according to the sequence corresponding to the target pixel point to obtain the decrypted data.
Optionally, the step of determining the character corresponding to the target pixel point 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 includes:
determining the type of the character corresponding to each target pixel point according to the corresponding relation between a 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 reverse process of a preset color value setting rule adopted when the target image is generated.
Optionally, the step of determining the target pixel points and the corresponding sequence in the target image according to an inverse process of a preset generation manner adopted when the target image is generated includes:
acquiring a preset replacement mode adopted when a target image is generated;
and determining target pixel points and corresponding sequences in the target image according to the reverse process of the preset replacement mode.
In a third aspect, an embodiment of the present invention provides a data encryption apparatus, where the apparatus includes:
the data to be encrypted acquisition module is used for acquiring data to be encrypted;
the gray value determining module is used for determining the gray value corresponding to the character contained in the data to be encrypted according to a preset gray value setting rule;
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 value and the gray value corresponding to each character;
and the data encryption module is used for generating a target image by utilizing the pixel points according to a preset generation mode and using the target image as the encrypted data corresponding to the data to be encrypted.
Optionally, the gray value determining module includes:
the type determining unit is used for determining the type of each character contained 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 a preset three-dimensional coordinate system as the RGB value corresponding to the character.
Optionally, the data encryption module includes:
a standby image acquisition unit for acquiring 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, where the apparatus includes:
the target image acquisition module is used for acquiring a target image;
the pixel point sequence determining module is used for determining target pixel points and corresponding sequences in the target image according to the reverse process of a preset generation mode adopted when the target image is generated;
the character determining module is used for determining a character corresponding to the target pixel point according to the reverse process of a preset color value setting rule adopted when the target image is generated and the reverse process of a 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 reverse process of a preset color value setting rule adopted when the target image is generated.
Optionally, the pixel point sequence determining module includes:
the replacement mode acquiring unit is used for acquiring a preset replacement mode adopted when the target image is generated;
and the second sequence determining unit is used for determining the target pixel points and the corresponding sequence 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 and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
a processor for implementing any of the above-described data encryption method steps or any of the above-described data decryption method steps when executing a program stored in the memory.
In a sixth aspect, the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements any of the above-mentioned data encryption method steps or any of the above-mentioned data decryption method steps.
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, 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 as the encrypted data corresponding to the data to be encrypted by using the pixel points according to the preset generation mode. Due to the fact that personalized images are abused due to reasons such as artistic styles, personal aesthetics and information explosion of the images, and the styles of the images are various, the data are encrypted to generate one image, the concealment of encrypted data can be improved, and the safety of the encrypted data is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a data encryption method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating the step S103 in FIG. 1;
FIG. 3 is a flowchart illustrating a specific 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 illustrating a specific step S402 in the embodiment shown in FIG. 4;
fig. 6 is a schematic structural diagram of a data encryption apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a data decryption apparatus 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 technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to improve the security of encrypted data, embodiments of the present invention provide a data encryption method, a data decryption device, an electronic device, and a computer-readable storage medium.
First, a data encryption method provided in an embodiment of the present invention is described below.
The data encryption method provided by the embodiment of the present invention may be applied to any electronic device that needs to encrypt data, for example, a computer, a mobile phone, a processor, and the like, and is not limited specifically herein. For convenience of description, the electronic device is hereinafter referred to simply as an electronic device.
As shown in fig. 1, a data encryption method, the method comprising:
s101, acquiring 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 the characters;
and S105, generating a target image by using the pixel points according to a preset generation mode, wherein the target image is used as the encrypted data corresponding to the data to be encrypted.
Therefore, 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, 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 as the encrypted data corresponding to the data to be encrypted by using the pixel points according to the preset generation mode. Due to the fact that personalized images are abused due to reasons such as artistic styles, personal aesthetics and information explosion of the images, and the styles of the images are various, the data are encrypted to generate one image, the concealment of encrypted data can be improved, and the safety of the encrypted data is improved.
In step S101, the electronic device may obtain data to be encrypted, where the data to be encrypted is data that needs to be encrypted. It is reasonable that the data to be encrypted may be data generated or stored by the electronic device itself, or may be data transmitted by other electronic devices. The form of the data to be encrypted may be any type of characters, such as chinese, english, korean, numerals, symbols, etc., and is not particularly limited thereto.
After obtaining the data to be encrypted, the electronic device may determine the gray value corresponding to the character included in the data to be encrypted according to a preset gray value setting rule, that is, execute step S102. In order to determine the gray value corresponding to the characters 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 gray value 100 corresponding to chinese, a gray value 227 corresponding to number, and the like.
In one embodiment, the electronic device may determine a type of each character included in the data to be encrypted, and further determine a grayscale value corresponding to the type of the majority of characters as a grayscale value corresponding to the character included in the data to be encrypted. For example, the data to be encrypted includes 10 characters, where 6 are chinese and 4 are numbers, so that the gray-level value corresponding to the chinese may be the gray-level value corresponding to the character included in the data to be encrypted.
In another embodiment, the preset gray value setting rule may be to determine the gray value according to a time period, for example, a day is divided into a plurality of time periods, each time period corresponds to one gray value, then the electronic device may determine the corresponding gray value according to the time period of the current time, and further determine the gray value as the gray value corresponding to the character included in the data to be encrypted.
For example, if the day is divided into 24 time periods from 0 point, which correspond to the gray scale values 100-123 in sequence, and the current time is 9 points and 10 points, the electronic device may determine the gray scale value 108 corresponding to the current time, and then may determine the gray scale value 108 corresponding to the character included in the data to be encrypted.
In 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 conveniently determine the color value corresponding to each character contained 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 can be determined according to factors such as the type of data needing to be encrypted, for example, a color value can be corresponding to each Chinese character, and the corresponding color value is determined according to the character arrangement sequence.
The color value is an RGB value, and the ranges of three components in the RGB value are all 0 to 255, so the color value can correspond to 255 × 255 × 255-16581375 characters, and since the number of the chinese characters is far less than that for the most complex chinese, 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 in sequence, and the step S102 may be executed first, and then the step S103 may be executed; step S103 may be executed first, and then step S102 may be executed; it is reasonable that step S102 and step S103 may be executed at the same time, and the embodiment of the present invention is not limited in detail herein.
After determining the gray value and the color value, the electronic device may execute the step S104, that is, determine the color value corresponding to each character and the pixel point corresponding to the gray value. The pixel point has two characteristics of color value and gray value, so after the two characteristics are determined, the pixel point can also be determined.
And then, the electronic equipment can utilize the pixel points to generate a target image according to a preset generation mode. In an embodiment, the electronic device may generate, according to a certain rule, a target image including only the pixel points by using the pixel points. For example, according to the arrangement sequence of characters in the data to be encrypted, pixel points corresponding to each character are arranged to obtain a target image.
For example, the electronic device may determine the preset 1000 pixels, and then generate the target image with the size of 100 × 100 using the 10000 pixels, which are 9000 pixels.
The target image can be used as the 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 requirements, the encrypted data is a picture, the concealment is high, and the security 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 character, a japanese character, a numeral, a symbol, and the like, and is not limited specifically herein. Furthermore, the electronic device may search for a correspondence between a preset gray value and a type, and determine a gray value corresponding to each character. For example, in the preset correspondence relationship between the gray value and the type, 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 preset correspondence between the gray-level values and the types in a table manner, for example, as shown in the following table:
serial number Type (B) Grey 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 character is type B, then its corresponding grayscale value may be determined to be grayscale value g 2.
Therefore, in this embodiment, the electronic device may determine the type of each character included in the data to be encrypted, and further determine the gray value corresponding to each character according to the corresponding relationship between the preset gray value and the type. Therefore, the electronic equipment can quickly and accurately determine the gray value corresponding to each character contained in the data to be encrypted.
As an implementation manner of the embodiment of the present invention, as shown in fig. 2, 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 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 generally consists of three components, and the position of the coordinate point in the three-dimensional coordinate system is also represented by the three components, the electronic device can pre-establish a three-dimensional coordinate system, that is, the 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 mode may be set according to factors such as encryption requirements, and is not specifically limited herein. For example, the electronic device may sequentially determine the position corresponding to each character in each quadrant according to the arrangement order of the characters included in the data to be encrypted. For another example, the electronic device may group characters according to the number of characters included in the data to be encrypted, and the characters in the same group determine 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 the corresponding position of each character in the preset three-dimensional coordinate system is determined, the electronic device may determine the color value corresponding to each character based on the corresponding position of each character in the preset three-dimensional coordinate system. In an embodiment, the coordinates of the corresponding position of each character in the preset three-dimensional coordinate system may be mathematically operated on a preset value, and the obtained value may be determined as the color value corresponding to the character.
For example, the electronic device determines that the coordinate of the corresponding position of the character 1 in the preset three-dimensional coordinate system is (155, 20, 254), and may determine a value obtained by subtracting 5 from each coordinate value of the coordinate as the color value corresponding to the character 1, that is, (155-5, 20-5, 254-5) ═ (150, 15, 249).
As can be seen, in this embodiment, the electronic device may determine, according to the preset distribution manner, a corresponding position of each character included in the data to be encrypted in the preset three-dimensional coordinate system, and determine the color value corresponding to each character based on the corresponding position of each character in the preset three-dimensional coordinate system. Because the coordinate values in the three-dimensional coordinate system and the color values of the pixel points in the image have the same characteristics and are enough in number, the color values corresponding to each character determined based on the corresponding position of each character in the preset three-dimensional coordinate system can meet the requirement of data encryption, and the calculation 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 value of the pixel is generally represented by RGB values, the coordinate value range of the predetermined 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 the RGB value corresponding to the character.
Under the condition that the coordinate value range of the preset three-dimensional coordinate system is (0, 255), since the coordinate of any position in the preset three-dimensional coordinate system can be used as a color value according with the image characteristic, after the electronic device determines the coordinate of the corresponding position of each character in the preset three-dimensional coordinate system, which is included in the data to be encrypted, the electronic device can 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.
For example, if the electronic device determines that the coordinates of the corresponding position of the character 2 in the predetermined three-dimensional coordinate system are (0, 125, 89), the electronic device may determine that the RGB value corresponding to the character 2 is (0, 125, 89).
As can be seen, in this embodiment, in the case that the coordinate value range of the preset three-dimensional coordinate system is (0, 255), the electronic device may determine the coordinates 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 calculation amount can be further reduced, so that the color value corresponding to each character contained in the data to be encrypted can be quickly determined.
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 the 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 color values corresponding to each character contained in the data to be encrypted and the pixel points corresponding to the gray values, the pixel points can be arranged according to a preset arrangement mode, and then the target image is generated.
In an 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 pixel points corresponding to each character from left to right according to the arrangement sequence of the characters included in the data to be encrypted 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 be 20 × 20, and further arrange the pixel points corresponding to each character from left to right according to the arrangement sequence of the 400 characters, where the pixel points corresponding to the first 20 characters form a first row of the target image, the pixel points corresponding to the next 20 characters form a second row of the target image, and so on, and the pixel points corresponding to the last 20 characters form a 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 pixel points corresponding to each character according to a mapping relationship between the characters included in the data to be encrypted and positions in the target image to obtain the target image.
For example, if 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 be 20 × 20, and the mapping relationship between the characters and the positions in the target image is that the character 1 corresponds to the tenth row and the fifth position, so that the electronic device may determine that the pixel points corresponding to the character 1 are located at the tenth row and 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 that the target image may be obtained.
As can be seen, 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, and can be changed at will, so that the security of the encrypted data is further improved.
As an implementation manner of the embodiment of the present invention, as shown in fig. 3, the step of generating the target image according to the preset generation manner by using the pixel point may include:
s301, acquiring a standby image;
the electronic device may acquire one image as a standby image, where the standby image may be any image, for example, an image stored locally by the electronic device, or an image acquired by the electronic device from another device, and it is reasonable if the electronic device has an image capturing function, or an image captured by the electronic device.
The size, format, included content, and the like of the above-mentioned standby image are not specifically limited herein in the embodiments of the present invention.
S302, replacing the pixel points in the standby image by the pixel points according to a preset replacement mode to generate a target image.
After the electronic equipment acquires the standby image, the electronic equipment can replace the pixel points in the standby image by using the pixel points corresponding to each character contained in the data to be encrypted according to a preset replacement mode, and then the target image is obtained. The preset replacement mode may be set according to factors such as an encryption requirement, the number of pixel points corresponding to each character included in the data to be encrypted, and the like, and is not specifically limited herein.
As an implementation manner, the electronic device may preset a corresponding relationship between each character included in the data to be encrypted and pixel points in the standby image, where the pixel points in the standby image are to be replaced. Furthermore, after the electronic device determines the pixel point corresponding to each character contained in the data to be encrypted, the corresponding pixel point to be replaced can be replaced by the pixel point corresponding to the character based on the corresponding relationship.
In order to make the target image more concealed, the number of pixel points included in the standby image can be far more than the number of characters included in the data to be encrypted, so that the difference of the obtained target image relative to the standby image is not large, even the difference of the target image and the standby image is difficult to find, and the safety of the encrypted data can be improved.
Therefore, in this embodiment, the electronic device may obtain the standby image, and replace the pixel points in the standby image with the pixel points corresponding to each character included in the data to be encrypted according to a preset replacement mode, so as to generate the target image. Therefore, the target image can be further concealed, and the safety of the encrypted data is further improved.
Compared with the data encryption method, the embodiment of the invention also provides a data decryption method. A data decryption method provided in an embodiment of the present invention is described below.
The data decryption method provided by the embodiment of the present invention may be applied to any electronic device that needs to decrypt data, for example, a computer, a mobile phone, a processor, and the like, and is not limited specifically herein. For convenience of description, the electronic device is hereinafter referred to simply as an electronic device. It may be the same device as the electronic device that executes the data encryption method or may be a different device.
As shown in fig. 4, a data decryption method, the method comprising:
s401, acquiring a target image;
s402, determining target pixel points and corresponding sequences in the target image according to the reverse process of a preset generation mode adopted when the target image is generated;
s403, determining characters corresponding to the target pixel points according to the reverse process of a preset color value setting rule adopted when the target image is generated and the reverse process of a 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.
As can be seen, in the scheme provided in the embodiment of the present invention, the electronic device may obtain the target image, determine the target pixel points 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, determine the characters corresponding to the target pixel points 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 points to obtain the decrypted data. By adopting the decryption method, the obtained target image processed by adopting the data encryption method provided by the embodiment can be decrypted.
In step S401, the electronic device may first acquire a target image. The target image is the encrypted data that needs to be decrypted.
The target image is generated according to a preset generation mode by utilizing pixel points corresponding to 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 inverse process of the preset generation mode. The target pixel points are pixel points corresponding to characters contained in the data to be encrypted, and the sequence corresponding to the target pixel points is the sequence of the pixel points corresponding to the characters contained in the data to be encrypted, namely the arrangement sequence of the characters contained in the data to be encrypted.
The reverse process of the preset generation mode may be preset in the electronic device, so as to process the acquired target image. It is reasonable to obtain the preset generation mode from the electronic device generating the target image or other devices storing the preset generation mode, and further determine the reverse process.
For example, the characters contained in the data to be encrypted are character a, character b, character c and character d, the corresponding pixel points are pixel points 1-4, and the 4 pixel points generate the target image according to the arrangement sequence from left to right. Then, the electronic device may determine that the target pixel points in the target image are pixel points 1-4, and the sequence of the 4 pixel points is 1-4 from left to right, which means that the arrangement sequence of the characters corresponding to the 4 pixel points in the data to be encrypted is 1-4.
In step S403, the gray value and the color value of the target pixel point in the target image are determined by using the preset gray value setting rule and the preset color value setting rule according to the characters included in the data to be encrypted when the data is encrypted, so that the electronic device can determine the character corresponding to the target pixel point according to the inverse process of the preset color value setting rule and the inverse process of the preset gray value setting rule.
The preset gray value setting rule and the preset color value setting rule may be set in the electronic device in advance in an inverse process, so as to process the acquired target image. It is reasonable to obtain the preset gray value setting rule and the preset color value setting rule from the electronic device that generates the target image or other devices that store the preset gray value setting rule and the preset color value setting rule, and determine the inverse process.
For example, if the preset gray-scale value setting rule is that a chinese character corresponds to a gray-scale value of 100 and the color value of the character "i" corresponds to (12, 56, 217), then if the gray-scale value of the target pixel point is 100 and the color value is (12, 56, 217), the electronic device may use the corresponding character as the chinese character "i".
After determining the corresponding characters and sequence of the target pixel point, the electronic device may execute step S404, that is, arrange the corresponding characters according to the corresponding sequence of the target pixel point, so as to obtain the decrypted data.
For example, the electronic device determines that the characters corresponding to the target pixel 11-the target pixel 16 are a, 1, C, f, 9, and #, respectively, and the sequence of the target pixel 11-the target pixel 16 is 6, 1, 2, 5, 4, and 3, then the electronic device may determine that the decrypted data is 1C #9 fa.
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 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 may include:
determining the type of the character corresponding to each target pixel point according to the corresponding relation between a 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 reverse process of a preset color value setting rule adopted when the target image is generated.
When encrypting data to obtain a target image, if the gray value corresponding to each character is determined according to the corresponding relationship between the preset gray value and the type, the electronic device may determine the type of the character corresponding to each target pixel point according to the corresponding relationship between the preset gray value and the type when decrypting the data.
For example, if the preset correspondence between the gray value and the type is an english correspondence gray value 55, the electronic device may determine that the type of the character corresponding to the target pixel point is english if the gray value of the target pixel point is 55.
Furthermore, the electronic device can determine 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 according to the reverse 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 each target pixel point can be determined from the target image, and the color value of each 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 reverse process of the preset color value setting rule.
It can be seen that, in this embodiment, the electronic device may determine the type of the character corresponding to each target pixel point according to the corresponding relationship between the preset gray value and the type, and determine 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 according to an inverse process of a preset color value setting rule adopted when generating the target image. It can be ensured that the correct decrypted data is obtained.
As an implementation manner of the embodiment of the present invention, as shown in fig. 5, the step of determining the target pixel points and the corresponding sequence in the target image according to an inverse process of a preset generation manner adopted when the target image is generated may include:
s501, acquiring a preset arrangement mode adopted when a target image is generated;
in order to accurately decrypt the target image, the electronic device may obtain the preset arrangement mode used when the target image is generated when the pixel points corresponding to the characters in the data to be encrypted are arranged according to the preset arrangement mode to generate the target image. The preset arrangement mode is an arrangement mode adopted when pixel points corresponding to characters contained in the data to be encrypted generate a target image.
S502, determining all pixel points in the target image as target pixel points;
in this embodiment, the pixel points in the target image are all pixel points corresponding to the characters included in the data to be encrypted, so that the electronic device can determine that all the pixel points in the target image are target pixel points.
S503, determining the corresponding sequence of the target pixel points according to the reverse process of the preset arrangement mode.
Furthermore, according to the inverse process of the preset arrangement mode, the electronic device can determine the sequence corresponding to the target pixel point. For example, when the target image is generated, the size of the target image is set according to the number of characters included 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 included 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 the sequence 1 to m corresponding to the left to right in sequence, and m is the number of the target pixel points.
As can be seen, in this embodiment, the electronic device may obtain the preset arrangement mode adopted when the target image is generated, determine all the pixel points in the target image as the target pixel points, and then determine the sequence corresponding to the target pixel points according to the inverse process of the preset arrangement mode. Therefore, the method and the device can ensure that the sequence corresponding to the target pixel point is accurately determined and the data decryption is accurately performed 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 the preset arrangement mode.
As an implementation manner of the embodiment of the present invention, the step of determining the target pixel points and the corresponding sequence in the target image according to an inverse process of a preset generation manner adopted when the target image is generated may include:
acquiring a preset replacement mode adopted when a target image is generated; and determining target pixel points and corresponding sequences in the target image according to the reverse process of the preset replacement mode.
In order to accurately decrypt data, the electronic device may obtain a preset replacement mode used when the target image is generated, when 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.
Furthermore, the electronic device can determine the target pixel points 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 the pixel points in the standby image with the pixel points corresponding to the characters based on the corresponding relationship between each character contained in the data to be encrypted and the pixel points in the standby image. The electronic device may determine the target pixel points and the corresponding sequence in the target image according to the correspondence between each character included in the data to be encrypted and the pixel points in the standby image.
As can be seen, in this embodiment, the electronic device may obtain a preset replacement mode adopted when generating the target image, and determine the target pixel points and the corresponding sequence in the target image according to an inverse process of the preset replacement mode. Therefore, the sequence corresponding to the target pixel point can be accurately determined under the condition that the target image is generated by replacing the pixel point in the standby image with the pixel point corresponding to the character in the data to be encrypted according to the preset replacement mode, and the accurate data decryption is ensured.
Corresponding to the data encryption method, the embodiment of the invention also provides a data encryption device. A data encryption device according to an embodiment of the present invention is described below.
As shown in fig. 6, a data encryption apparatus, the apparatus comprising:
a to-be-encrypted data acquisition module 610, configured to acquire data to be encrypted;
a gray value determining module 620, 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;
a color value determining module 630, configured to determine, according to a preset color value setting rule, a color value corresponding to each character included in the data to be encrypted;
a pixel point determining module 640, configured to determine a pixel point corresponding to the color value and the gray value corresponding to each character;
and the data encryption module 650 is configured to generate a target image as encrypted data corresponding to the data to be encrypted according to a preset generation manner by using the pixel point.
Therefore, 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, 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 as the encrypted data corresponding to the data to be encrypted by using the pixel points according to the preset generation mode. Due to the fact that personalized images are abused due to reasons such as artistic styles, personal aesthetics and information explosion of the images, and the styles of the images are various, the data are encrypted to generate one image, the concealment of encrypted data can be improved, and the safety of the encrypted data is improved.
As an implementation manner of the embodiment of the present invention, the gray value determining module 620 may include:
a type determining unit (not shown in fig. 6) for determining a type of each character included in the data to be encrypted;
and a gray value determining unit (not shown in fig. 6) configured to determine a gray value corresponding to each character according to a preset correspondence relationship between the gray value and the type.
As an implementation manner of the embodiment of the present invention, the 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;
and a color value determining unit (not shown in fig. 6) configured to determine a color value corresponding to each character based on a corresponding position of 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 color value determination unit may include:
and a color value determining subunit (not shown in fig. 6) for determining coordinates of a corresponding position of each character in the preset three-dimensional coordinate system as an RGB value corresponding to the character.
As an implementation manner of the embodiment of the present invention, the data encryption module 650 may include:
and a first data encryption unit (not shown in fig. 6) configured to arrange the pixel points according to a preset arrangement manner, so as to 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 acquiring unit (not shown in fig. 6) for acquiring a standby image;
and a second data encryption unit (not shown in fig. 6) configured to replace the pixel points in the standby image with the pixel points according to a preset replacement mode to generate a target image.
Corresponding to the data decryption method, the embodiment of the invention also provides a data decryption device. A data decryption apparatus according to an embodiment of the present invention is described below.
As shown in fig. 7, a data decryption apparatus, the apparatus comprising:
a target image obtaining module 710 for obtaining a target image;
a pixel point sequence determining module 720, configured to determine a target pixel point in the target image and a corresponding sequence according to an inverse process of a preset generation manner adopted when the target image is generated;
a character determining module 730, configured to determine a character corresponding to the target pixel point 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.
As can be seen, in the scheme provided in the embodiment of the present invention, the electronic device may obtain the target image, determine the target pixel points 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, determine the characters corresponding to the target pixel points 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 points to obtain the decrypted data. By adopting the decryption method, the obtained target image processed by adopting the data encryption method provided by the embodiment can be decrypted.
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 target pixel point according to a preset correspondence between a gray value and the type;
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 point, the character corresponding to each target pixel point according to an inverse process of a preset color value setting rule adopted when the target image is generated.
As an implementation manner of the embodiment of the present invention, the pixel point order determining module 720 may include:
an arrangement acquiring unit (not shown in fig. 7) configured to acquire a preset arrangement used when the target image is generated;
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 point according to an inverse process of the preset arrangement manner.
As an implementation manner of the embodiment of the present invention, the pixel point order determining module 730 may include:
an alternative acquiring unit (not shown in fig. 7) for acquiring a preset alternative employed in generating the target image;
a second order determining unit (not shown in fig. 7) configured to determine, according to an inverse process of the preset replacement manner, a target pixel point in the target image and a corresponding order.
An embodiment of the present invention further provides an electronic device, as shown in fig. 8, 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 mutual communication 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 embodiments described above when executing the program stored in the memory 803.
Therefore, 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, 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 as the encrypted data corresponding to the data to be encrypted by using the pixel points according to the preset generation mode. Due to the fact that personalized images are abused due to reasons such as artistic styles, personal aesthetics and information explosion of the images, and the styles of the images are various, the data are encrypted to generate one image, the concealment of encrypted data can be improved, and the safety of the encrypted data is improved.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a 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 processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
An embodiment of the present invention further provides an electronic device, as shown in fig. 9, 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 complete mutual communication through the communication bus 904,
a memory 903 for storing computer programs;
the processor 901 is configured to implement the data decryption method according to any of the embodiments described above when executing the program stored in the memory 903.
As can be seen, in the scheme provided in the embodiment of the present invention, the electronic device may obtain the target image, determine the target pixel points 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, determine the characters corresponding to the target pixel points 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 points to obtain the decrypted data. By adopting the decryption method, the obtained target image processed by adopting the data encryption method provided by the embodiment can be decrypted.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a 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 processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
The embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the data encryption method according to any of the above embodiments is implemented.
It can be seen that in the scheme provided in the embodiment of the present invention, when the computer program is executed by the processor, the data to be encrypted may be obtained, the gray value corresponding to the character included in the data to be encrypted is determined according to the preset gray value setting rule, the color value corresponding to each character included in the data to be encrypted is determined according to the preset color value setting rule, further, 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 manner, and is used as the encrypted data corresponding to the data to be encrypted. Due to the fact that personalized images are abused due to reasons such as artistic styles, personal aesthetics and information explosion of the images, and the styles of the images are various, the data are encrypted to generate one image, the concealment of encrypted data can be improved, and the safety of the encrypted data is improved.
The embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the data decryption method according to any of the above embodiments is implemented.
It can be seen that, in the scheme provided in the embodiment of the present invention, when the computer program is executed by the processor, the target image may be obtained, the target pixel points and the corresponding sequence in the target image are determined according to the inverse process of the preset generation manner 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 then the corresponding characters are arranged according to the sequence corresponding to the target pixel points, so as to obtain the decrypted data. By adopting the decryption method, the obtained target image processed by adopting the data encryption method provided by the embodiment can be decrypted.
It should be noted that, for the above-mentioned apparatus, electronic device and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the component descriptions of the method embodiments.
It is further noted that, herein, relational terms such as first and second, and the like may be 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. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a relevant manner, and the same and similar components in all the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (18)

1. A method for data encryption, 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 value and the gray value corresponding to each character;
and generating a target image as the encrypted data corresponding to the data to be encrypted by using the pixel points according to a preset generation mode.
2. The method according to claim 1, wherein the step of determining the gray-level value corresponding to the character included in the data to be encrypted according to a preset gray-level value setting rule comprises:
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 the color value corresponding to each character included in the data to be encrypted according to a preset color value setting rule comprises:
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 a color value corresponding to each character based on the corresponding position of each character in a preset three-dimensional coordinate system.
4. The method of claim 3, wherein the predetermined three-dimensional coordinate system has a coordinate value range of (0, 255);
the step of determining a color value corresponding to each character based on a corresponding position of each character in a preset three-dimensional coordinate system includes:
and determining the coordinates of the corresponding position of each character in a preset three-dimensional coordinate system as the RGB value corresponding to the character.
5. The method according to any one of claims 1 to 4, wherein the step of generating the target image by using the pixel points according to a preset generation mode comprises:
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.
6. A method for data decryption, the method comprising:
acquiring a target image;
determining target pixel points and corresponding sequences in the target image according to an 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 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 arranging the corresponding characters according to the sequence corresponding to the target pixel point to obtain the decrypted data.
7. The method according to claim 6, wherein the step of determining the character corresponding to the target pixel point according to an inverse process of a preset color value setting rule employed in generating the target image and an inverse process of a preset gray value setting rule employed in generating the target image comprises:
determining the type of the character corresponding to each target pixel point according to the corresponding relation between a 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 reverse process of a preset color value setting rule adopted when the target image is generated.
8. The method according to claim 6 or 7, wherein the step of determining the target pixel points and the corresponding sequence in the target image according to an inverse process of a preset generation manner adopted when the target image is generated comprises:
acquiring a preset replacement mode adopted when a target image is generated;
and determining target pixel points and corresponding sequences in the target image according to the reverse process of the preset replacement mode.
9. An apparatus for encrypting data, the apparatus 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 the gray value corresponding to the character contained in the data to be encrypted according to a preset gray value setting rule;
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 value and the gray value corresponding to each character;
and the data encryption module is used for generating a target image by utilizing the pixel points according to a preset generation mode and using the target image as the encrypted data corresponding to the data to be encrypted.
10. The apparatus of claim 9, wherein the gray value determination module comprises:
the type determining unit is used for determining the type of each character contained 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.
11. The apparatus of claim 9, 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.
12. The apparatus of claim 11, wherein the predetermined three-dimensional coordinate system has a coordinate value range of (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 a preset three-dimensional coordinate system as the RGB value corresponding to the character.
13. The apparatus of any of claims 9-12, wherein the data encryption module comprises:
a standby image acquisition unit for acquiring 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.
14. An apparatus for decrypting data, the apparatus comprising:
the target image acquisition module is used for acquiring a target image;
the pixel point sequence determining module is used for determining target pixel points and corresponding sequences in the target image according to the reverse process of a preset generation mode adopted when the target image is generated;
the character determining module is used for determining a character corresponding to the target pixel point according to the reverse process of a preset color value setting rule adopted when the target image is generated and the reverse process of a 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.
15. The apparatus of claim 14, 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 reverse process of a preset color value setting rule adopted when the target image is generated.
16. The apparatus of claim 14 or 15, wherein the pixel point order determination module comprises:
the replacement mode acquiring unit is used for acquiring a preset replacement mode adopted when the target image is generated;
and the second sequence determining unit is used for determining the target pixel points and the corresponding sequence in the target image according to the reverse process of the preset replacement mode.
17. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 or 6 to 8 when executing a program stored in the memory.
18. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method steps of any one of claims 1 to 5 or 6 to 8.
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 true CN111368310A (en) 2020-07-03
CN111368310B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113919954A (en) * 2021-10-14 2022-01-11 深圳市诚堡科技有限公司 Managed transaction data monitoring method
CN114092488A (en) * 2021-10-21 2022-02-25 广州金域医学检验中心有限公司 Image processing method, image processing device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101627620A (en) * 2007-05-31 2010-01-13 株式会社Pfu Electronic document encryption system, decryption system, program and method
CN103220551A (en) * 2013-03-12 2013-07-24 重庆市科学技术研究院 Digital resource encryption and decryption system and method based on image processing
CN103246830A (en) * 2013-04-28 2013-08-14 北京小米科技有限责任公司 Encrypting processing method, encrypting processing device, deciphering processing method and deciphering processing device of client side scripting
CN106330976A (en) * 2016-11-03 2017-01-11 武汉斗鱼网络科技有限公司 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 (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101627620A (en) * 2007-05-31 2010-01-13 株式会社Pfu Electronic document encryption system, decryption system, program and method
CN103220551A (en) * 2013-03-12 2013-07-24 重庆市科学技术研究院 Digital resource encryption and decryption system and method based on image processing
CN103246830A (en) * 2013-04-28 2013-08-14 北京小米科技有限责任公司 Encrypting processing method, encrypting processing device, deciphering processing method and deciphering processing device of client side scripting
CN106330976A (en) * 2016-11-03 2017-01-11 武汉斗鱼网络科技有限公司 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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113919954A (en) * 2021-10-14 2022-01-11 深圳市诚堡科技有限公司 Managed transaction data monitoring method
CN114092488A (en) * 2021-10-21 2022-02-25 广州金域医学检验中心有限公司 Image processing method, image processing device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN111368310B (en) 2023-05-02

Similar Documents

Publication Publication Date Title
CN108665403B (en) Digital watermark embedding method, digital watermark extracting method, digital watermark embedding device, digital watermark extracting device and digital watermark system
US9866378B2 (en) Encryption method, encryptor, and encryption system for encrypting electronic data by splitting electronic data
CN107610191B (en) Color image encryption method and device
WO2021027258A1 (en) Model parameter determination method and apparatus, and electronic device
CN110245469B (en) Webpage watermark generation method, watermark analysis method, device and storage medium
EP2945374A2 (en) Positioning of projected augmented reality content
CN110751149A (en) Target object labeling method and device, computer equipment and storage medium
US11057214B2 (en) Authentication apparatus using visual cryptography and method thereof
CN111368310B (en) Data encryption and decryption methods and devices, electronic equipment and storage medium
US11727701B2 (en) Techniques to determine document recognition errors
KR20190115442A (en) Display method, program and terminal
US9030378B2 (en) Sharing display processing system, display processing system, and display method
CN112633146B (en) Multi-pose face gender detection training optimization method, device and related equipment
CN114036542A (en) Data encryption and decryption method and computer storage medium
CN106228194B (en) Image lookup method and device
CN112055244A (en) Image acquisition method and device, server and electronic equipment
CN104123062B (en) A kind of information processing method and electronic equipment
US20160020902A1 (en) Key Generating Method and Apparatus
CN110232284B (en) Image encryption method and device
CN108122200A (en) Image split-joint method and device
CN110531911B (en) Screen capture information control method and device, computer equipment and storage medium
CN109905765B (en) Video tracing method and device
CN113160126B (en) Hardware Trojan detection method, hardware Trojan detection device, computer equipment and storage medium
CN113158167B (en) Verification code implementation method, electronic equipment and computer readable storage medium
CN106055416B (en) Method and device for data cross-application transfer

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