CN114036542A - Data encryption and decryption method and computer storage medium - Google Patents

Data encryption and decryption method and computer storage medium Download PDF

Info

Publication number
CN114036542A
CN114036542A CN202111347955.0A CN202111347955A CN114036542A CN 114036542 A CN114036542 A CN 114036542A CN 202111347955 A CN202111347955 A CN 202111347955A CN 114036542 A CN114036542 A CN 114036542A
Authority
CN
China
Prior art keywords
image
information
encrypted
information image
key
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111347955.0A
Other languages
Chinese (zh)
Inventor
孙巍巍
莫华晓
范航宇
刘永亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba China Co Ltd
Original Assignee
Alibaba China 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 Alibaba China Co Ltd filed Critical Alibaba China Co Ltd
Priority to CN202111347955.0A priority Critical patent/CN114036542A/en
Publication of CN114036542A publication Critical patent/CN114036542A/en
Pending legal-status Critical Current

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/58Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
    • G06F16/583Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually using metadata automatically derived from the content
    • 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/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6245Protecting personal data, e.g. for financial or medical purposes

Abstract

The embodiment of the application provides a data encryption and decryption method, electronic equipment, a computer storage medium and a computer program product, wherein the data encryption method comprises the following steps: acquiring information to be encrypted and a key for encrypting the information to be encrypted; converting information to be encrypted into an information image, and converting the key into a binary key image matched with the information image according to the size of the information image; performing image fusion processing on the information image and the binary key image according to pixel positions; and obtaining the encrypted information image according to the result of the image fusion processing. By the embodiment of the application, information safety in a scene that a physical entity is required to serve as an information presentation carrier is realized.

Description

Data encryption and decryption method and computer storage medium
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a data encryption and decryption method and a computer storage medium.
Background
With the development of information technology, various digitalized information contents are widely applied to various industries, and bring convenience to people.
At the same time, however, a great deal of personal information needs to be transmitted over the internet for communication, transaction, payment, logistics, entertainment, etc., which may lead to theft and illegal use thereof. For example, after acquiring the information, black and gray product practitioners on the internet are used to portray users and perform actions such as targeted advertisement delivery and direct merchandising, and even more, the information is used by some lawbreakers to perform bad illegal actions such as fixed-point fraud on target users. Therefore, securing personal information of a user becomes a hot spot in internet technology.
In the conventional method, information to be encrypted is directly encrypted through a key to ensure information security, but the method is not suitable in some scenes, especially scenes requiring a physical entity as an information presentation carrier. Taking logistics express as an example, when express delivery is performed, privacy information such as names, addresses, telephone numbers and the like of users needs to be physically changed, then the physical menu is transmitted along with packages, and a transmission link relates to a sender, a storage party, a transfer party, a delivery party, a receiver and the like. In this scenario, if a traditional key manner is adopted, although information encryption can be achieved, multiple parties such as a storage party, a transfer party, a delivery party, a recipient and the like in the express delivery process cannot acquire the information of the goods to be delivered, so that the goods cannot be delivered and dispatched.
Therefore, how to implement information protection under the above-mentioned scenario becomes an urgent problem to be solved.
Disclosure of Invention
In view of the above, embodiments of the present application provide a data encryption and decryption scheme to at least partially solve the above problems.
According to a first aspect of embodiments of the present application, there is provided a data encryption method, including: acquiring information to be encrypted and a key for encrypting the information to be encrypted; converting information to be encrypted into an information image, and converting the key into a binary key image matched with the information image according to the size of the information image; performing image fusion processing on the information image and the binary key image according to pixel positions; and obtaining the encrypted information image according to the result of the image fusion processing.
According to a second aspect of embodiments of the present application, there is provided a data decryption method, including: acquiring an encrypted information image carrying encrypted information and a binary key image generated based on a key, wherein the key is the same as an encryption key used by the encrypted information in the encrypted information image; fusing and superposing the encrypted information image and the binary key image; and acquiring a decryption information image corresponding to the encryption information image according to the fusion superposition result, wherein the decryption information image contains the plaintext of the encryption information.
According to a third aspect of embodiments of the present application, there is provided an electronic apparatus, including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus; the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the corresponding operation of the method according to the first aspect or the second aspect.
According to a fourth aspect of embodiments of the present application, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements a method according to the first or second aspect.
According to the data encryption and decryption scheme provided by the embodiment of the application, on one hand, the information to be encrypted and the secret key are imaged through the data encryption scheme, and then the information to be encrypted and the secret key are subjected to image fusion processing, so that information encryption is realized. Therefore, after the information is encrypted by the key image, even if the information is printed on an entity such as a bill, the information can not be identified by naked eyes, the information can be safely transmitted, and the method is suitable for scenes needing a physical entity as an information presentation carrier so as to realize the information safety in the scenes.
On the other hand, according to the data decryption scheme in the embodiment of the application, only the key used in encrypting information needs to be provided, namely, the binary key image corresponding to the key and the encrypted information image generated after encryption can be used for obtaining the decrypted information image through fusion and superposition of the binary key image and the encrypted information image, and the original plaintext information can be obtained from the decrypted information image. The finally decrypted plaintext information can still be presented in the form of a visual image and is obtained through human eye identification, so that the problem of automatic and large-scale information leakage can be effectively avoided, and information safety in a scene that a physical entity is required to serve as an information presentation carrier is realized.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be 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 described in the embodiments of the present application, and other drawings can be obtained by those skilled in the art according to the drawings.
FIG. 1 is a schematic diagram of an exemplary system to which a data encryption/decryption method according to an embodiment of the present application may be applied;
FIG. 2 is a flowchart illustrating steps of a data encryption method according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating steps of a data decryption method according to the second embodiment of the present application;
fig. 4A is a flowchart of a data encryption and decryption process according to a third embodiment of the present application;
FIG. 4B is a diagram illustrating an example of a scenario in the embodiment shown in FIG. 4A;
fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application shall fall within the scope of the protection of the embodiments in the present application.
The following further describes specific implementations of embodiments of the present application with reference to the drawings of the embodiments of the present application.
Fig. 1 illustrates an exemplary system to which a data encryption/decryption scheme according to an embodiment of the present application is applied. As shown in fig. 1, the system 100 may include a server 102, a communication network 104, and/or one or more user devices 106, illustrated in fig. 1 as a plurality of user devices.
Server 102 may be any suitable server for storing and communicating information, data, programs, and/or any other suitable type of content. In some embodiments, server 102 may perform any suitable functions. For example, in some embodiments, the server 102 may be used to transfer keys between user devices. As an optional example, in some embodiments, the server 102 may also be used to update the key sent to the user equipment based on a preset update algorithm.
In some embodiments, the communication network 104 may be any suitable combination of one or more wired and/or wireless networks. For example, the communication network 104 can include any one or more of the following: the network may include, but is not limited to, the internet, an intranet, a Wide Area Network (WAN), a Local Area Network (LAN), a wireless network, a Digital Subscriber Line (DSL) network, a frame relay network, an Asynchronous Transfer Mode (ATM) network, a Virtual Private Network (VPN), and/or any other suitable communication network. The user device 106 can be connected to the communication network 104 by one or more communication links (e.g., communication link 112), and the communication network 104 can be linked to the server 102 via one or more communication links (e.g., communication link 114). The communication link may be any communication link suitable for communicating data between the user device 106 and the server 102, such as a network link, a dial-up link, a wireless link, a hardwired link, any other suitable communication link, or any suitable combination of such links.
The user devices 106 may include any one or more user devices suitable for obtaining keys, updating keys, capturing images, presenting images, and the like. In some embodiments, user devices 106 may comprise any suitable type of device. For example, in some embodiments, user device 106 may include a mobile device, a unifonn information handling dedicated device, a tablet computer, a laptop computer, a desktop computer, a wearable computer, and/or any other suitable type of user device. In some embodiments, the user device 106 may encrypt an information image corresponding to the information to be encrypted based on a binary key image corresponding to the key, and generate the encrypted information image to be printed on a physical entity, such as a solid bill, that can carry the information image. In other embodiments, the user device 106 may capture an encrypted information image carried on a physical entity, such as a solid facesheet, and decrypt it using a binary key image corresponding to the key to obtain the plaintext of the original information.
Although server 102 is illustrated as one device, in some embodiments, any suitable number of devices may be used to perform the functions performed by server 102. For example, in some embodiments, multiple devices may be used to implement the functions performed by the server 102. Alternatively, the functionality of the server 102 may be implemented using a cloud service.
Based on the above system, the embodiments of the present application provide a data encryption and decryption scheme, and the following description is provided by a plurality of embodiments.
Example one
Referring to fig. 2, a flowchart illustrating steps of a data encryption method according to a first embodiment of the present application is shown.
The data encryption method of the embodiment comprises the following steps:
step S202: and acquiring information to be encrypted and a key for encrypting the information to be encrypted.
The information to be encrypted may be information that needs to be encrypted in the transfer process, such as personal information, business security data, and the like, and particularly information that needs to be encrypted and carried by a physical entity, including but not limited to logistics express information, take-away information, authentication information, and the like. The information is usually character information, and may be any one or any combination of letters, numbers, symbols, and the like. But not limited thereto, simple graphic symbol information, such as triangle, circle, rectangle, various simple sketched line graphics, etc., may also be applied to the solution of the embodiment of the present application.
For the key, the encrypting party and the decrypting party may be agreed in advance. In one possible approach, the key may be a binarization sequence of sufficient length that is generated using a key seed (seed). The generation of the key may be performed at any time before the information to be encrypted is encrypted, either immediately or prior to the generation of the information image from the image of the information to be encrypted, which is also referred to as a pre-key. Therefore, the generation and the use of the key in the embodiment of the application are more flexible and convenient. In the embodiment of the present application, a manner of generating a key is described as an example, but as described above, a manner of generating a key immediately is also applicable to the scheme of the embodiment of the present application.
Step S204: and converting the information to be encrypted into an information image, and converting the key into a binary key image matched with the information image according to the size of the information image.
In a feasible mode, if the information to be encrypted is character information, a character image is generated for the whole character information; similarly, when the information to be encrypted is graphical symbol information, a graphical symbol image may also be generated for the graphical symbol information as a whole.
In another possible way, if the information to be encrypted is character information, each character in the information to be encrypted can be acquired, and each character is converted into a corresponding character information image. Similarly, if the information to be encrypted is a combination of a plurality of graphic symbol information, each graphic symbol can be obtained and converted into a corresponding graphic symbol image; if the information to be encrypted is the combination of the characters and the graphic symbols, obtaining each character and each graphic symbol, and respectively converting the character and the graphic symbol into corresponding character information images and graphic symbol images. By splitting the data into single characters or graphic symbols, the data can be processed in units of characters or graphic symbols in subsequent processing, so that materials are provided for achieving a better data encryption effect.
Further alternatively, a plurality of character information images corresponding to each character may be searched and obtained from a database in which the character information images are prestored; and for each character, selecting one character information image from the corresponding character information images according to a preset rule as the character information image matched with the character. In this way, a large number of character information images are stored in the database in advance, and the relationship between the character information images and the characters is N:1, wherein N is greater than 1. For each character, each of the N character information images corresponding thereto is an image corresponding to the character, but the shape of the character in each image is different. When selecting a character information image from a plurality of character information images, the selection may be performed according to a preset rule, and the preset rule may be set by a person skilled in the art according to actual requirements, such as random selection, sequential selection, and the like, which is not limited by the embodiment of the present application. In this way, the security of the information can be improved. In the embodiments of the present application, the numbers "plural" and "plural" relating to "plural" mean two or more unless otherwise specified. Of course, the case where N is equal to 1 is also applicable to the scheme of the embodiment of the present application.
After the information image is obtained, the key can be converted into a binary key image matching the information image according to the size of the information image. If the information image is obtained by integrally converting the information to be encrypted, the key can be directly converted into a binary key image matched with the information image according to the size of the information image obtained by conversion; if the information image is obtained based on the image corresponding to a single character or the image corresponding to a single graphic symbol in the information to be encrypted, the key is converted into a binary key image matched with the information image according to the total size of the information image formed by the single images. In a specific implementation, the bits corresponding to the size of the information image may be calculated, and if 60 × 80 is assumed, the binarization sequence corresponding to the key may be truncated based on the size to obtain a binarization sequence of a corresponding length, and then the binarization sequence is converted into a binarization key image. Or, assuming that, in a feasible manner, a binarization sequence corresponding to the key may be obtained first; intercepting the binarization sequence according to the size of the information image to obtain a binarization matrix matched with the size of the information image; and converting the binary matrix into a binary key image. The intercepted binarization sequence is expressed as a binarization matrix, so that the speed and efficiency of converting the binarization sequence into a binarization key image can be effectively improved.
In a feasible manner, in order to reduce the subsequent calculation amount and simplify the subsequent encryption processing in the manner of converting each character into a corresponding character information image, the binarization processing and the uniform size processing may be performed on the character information image corresponding to each character, respectively, to obtain a binarization character information image having a uniform size corresponding to each character. In this way, the character information image is in the form of a bitmap with a uniform size, and the calculation of the bit corresponding to the size of the information image is simpler. For example, if the size of each character information image is 40 × 60, and 4 character information images in total, that is, the size of the total information image is 40 × 60 × 4 — 40 × 240 — 9600, 9600 bits can be directly extracted from the binarization sequence corresponding to the key. The 9600bit is converted into a binarization matrix of 40 × 240 by rows (240 bits per row) or columns (40 bits per column) or by the zig-zag sequence, and the binarization matrix is converted into a binarization key image. In this way, since the character information image is also subjected to binarization processing, that is, both the information image and the key image are binarized images, the calculation is simplified and convenient in the subsequent encryption processing. This may also be used when the information to be encrypted includes graphical symbols, which is not described herein.
In addition, a graphical bottom plate can be generated for the information to be encrypted according to the size of the character information image corresponding to each character; and according to the sequence of the characters in the information to be encrypted, placing the character information image corresponding to each character in the graphical master to generate the information image corresponding to the information to be encrypted. Although each character information image can be directly spliced to generate a final information image, each splicing needs to allocate new stored computational resources, and the storage resources and the computational resources can be allocated to the final information image to be generated at one time by generating the graphical master, so that the resource consumption is saved, and the information image generation efficiency is improved.
Step S206: and carrying out image fusion processing on the information image and the binary key image according to the pixel position.
In this step, the pixel positions are used to determine the corresponding relationship between the pixel points in the two images, and based on this, the fusion processing of the two images can be performed. In one possible approach, the image fusion process may be implemented by way of a pixel value exclusive-or process. For example, in the case where the information image and the binarization key image are both binarized images, the exclusive-or processing for both can be simply realized as exclusive-or processing between pixel values of 0 and 1. Therefore, the two images are both binary images, and the speed and the efficiency of encryption processing can be greatly improved.
For example, a threshold value of one pixel value such as 127 may be set, and if the pixel value of a certain pixel point of the information image is 156 and is greater than 127, when performing the exclusive-or processing with the binary key image, if the pixel value of the corresponding pixel point in the binary key image is 1, the result of the exclusive-or processing is 1; and if the pixel value of the corresponding pixel point in the binary key image is 0, the result of the exclusive or processing is 0. Or, it can be simply considered that, if the pixel value of the pixel point of the information image is less than or equal to 127, the pixel point is considered to be biased to black, and the pixel value can be considered to be 1; if the pixel value of the pixel point of the information image is greater than 127, the pixel point is considered to be biased to white, and the pixel value can be considered to be 0. Based on this, the result of exclusive or processing of the information image and the binary key image is obtained.
Step S208: and obtaining the encrypted information image according to the result of the image fusion processing.
After the information image and the binary key image are subjected to image fusion, the information to be encrypted is not easy to identify any more, for example, after the information image and the binary key image are subjected to pixel value exclusive-or processing according to pixel positions, the obtained information image is also a binary image, and a new information image is generated by fusing the original information image and the binary key image, so that the effective encryption of the information to be encrypted is realized.
It should be noted that, if a graphical master is used when generating an information image corresponding to information to be encrypted, in an alternative, a positioning information reserved position may be set in the graphical master, and this step may also be implemented as: obtaining an encrypted main information image according to the result of the XOR processing; based on the main information image, adding a positioning mark at a positioning information reserved position of the graphical master; and generating an encrypted information image according to the main information image and the positioning mark. The positioning mark can be used for accurately positioning the image part needing to be decrypted in the subsequent decryption.
In an application scenario of the embodiment of the application, the generated encrypted information image may be printed on a physical entity, for example, on an entity sheet, so that information transmission may be achieved, information leakage may be avoided, and information security is effectively guaranteed.
Therefore, according to the embodiment, the information to be encrypted and the key are imaged, and then the information to be encrypted and the key are subjected to exclusive or processing based on the pixel value, so that information encryption is realized. Therefore, after the information is encrypted by the key image, even if the information is printed on an entity such as a bill, the information can not be identified by naked eyes, the information can be safely transmitted, and the method is suitable for scenes needing a physical entity as an information presentation carrier so as to realize the information safety in the scenes.
The data encryption method of the present embodiment may be performed by any suitable electronic device having data processing capabilities, including but not limited to: server, mobile terminal (such as mobile phone, PAD, etc.), PC, etc.
Example two
Referring to fig. 3, a flowchart of steps of a data decryption method according to the second embodiment of the present application is shown.
The data decryption method of the embodiment comprises the following steps:
step S302: and acquiring an encrypted information image carrying encrypted information and a binary key image generated based on a key.
Wherein the key is the same as an encryption key used to encrypt the information image. In the embodiment of the present application, the encrypted information image may be a binarized encrypted information image obtained by the data encryption method described in the first embodiment, but may also be an image obtained by performing fusion processing on an information image and a key image by using a similar principle. The key used for decrypting the encrypted information image is the same as the key used for encrypting the information image, and the key can be transmitted in any appropriate secure transmission mode, which is not limited in the embodiment of the application.
In one possible approach, the generation of the binary key image based on the key may be implemented as: acquiring a binarization sequence corresponding to the key, and intercepting the binarization sequence according to the size of the encrypted information image to obtain a binarization matrix matched with the size of the encrypted information image; and converting the binary matrix into a binary key image. It should be noted that, in the present embodiment, for the reason of image capture, the size of the encrypted information image obtained by image capture may not be consistent with the size of the original encrypted information image (e.g., the encrypted information image generated in the first embodiment). However, the subsequent decryption process can be performed as long as the size of the binary key image and the size of the encrypted information image are kept the same. In addition, for the specific implementation of generating the binary key image based on the key, reference may be made to the description related to generating the binary key image in the first embodiment, and details are not repeated here.
In the case that the encrypted information image has the positioning mark, optionally, image acquisition may be performed on the entity bearing the encrypted information image to obtain an acquired image containing the encrypted information image; and determining a positioning mark from the acquired image, and acquiring an encrypted information image according to the positioning mark. By the method, the encrypted information image can be accurately positioned and acquired.
In a specific alternative, when the encrypted information image is obtained according to the positioning mark, the information image area may be obtained according to the positioning mark; carrying out affine transformation on the information image area; and performing binarization processing on the information image area subjected to affine transformation to obtain an encrypted information image. This is because the entity bearing the encrypted information image may deform the encrypted information image during the transmission process, and the deformation may be corrected by affine transformation, thereby avoiding abnormal decryption or incorrect decrypted information due to deformation. Further alternatively, the information image area subjected to affine transformation may be subjected to uniform size processing to be processed into a size suitable for decryption.
Step S304: and fusing and superposing the encrypted information image and the binary key image.
In one possible approach, this step can be implemented as: and carrying out pixel value exclusive OR processing on the encrypted information image and the binary key image according to the pixel position. As described above, the encrypted information image is usually a binarized image, and therefore, the process of performing the pixel value exclusive or process on the encrypted information image and the binarized key image can be regarded as the reverse process of performing the encryption process on the information image using the binarized key image as described above, and in this way, a more clear and easily recognizable decrypted information image with less noise can be obtained.
In another possible way, this step can be implemented as: and overlapping the pixel blocks of the encrypted information image and the binary key image according to the preset pixel block size and the preset pixel position. The preset pixel block size can be set by a person skilled in the art according to actual requirements, and the smaller the block is, the higher the precision is. In this way, black blocks + black blocks > black blocks; black blocks + white blocks- > black blocks; white block + white block — > white block. In this way, OCR decryption recognition can be effectively resisted due to the existence of noise.
Step S306: and acquiring a decryption information image corresponding to the encryption information image according to the fusion superposition result.
Through the fusion and superposition processing, the decryption information image containing the encryption information plaintext can be obtained, and the encryption information plaintext can be identified by naked eyes from the decryption information image.
However, in some cases, the encrypted information image may be deformed greatly due to transmission and the like, which causes deviation between the positioning and affine transformation of the encrypted information image after being acquired, and further causes the plaintext information obtained after decryption to be difficult to identify. Based on this, in a feasible manner of this embodiment, the encrypted information image may also be subjected to an offset operation according to a preset offset position; and fusing and superposing the encrypted information image subjected to the offset operation and the binary key image to obtain an alternative decrypted information image corresponding to the offset position, wherein the alternative decrypted information image comprises plaintext information corresponding to the encrypted information. That is, the offset deformation that may be generated by the encrypted information is corrected by the offset operation, so that the decrypted information can obtain a more correct result. Wherein the preset offset positions can be set by those skilled in the art as appropriate according to actual situations, such as eight offset positions of [0, -1], [ -1,0], [ -1, -1], [0,1], [1,0], [1,1], [1, -1], [ -1,1] for the encrypted information image, respectively, eight offset operations are performed. Accordingly, the finally obtained alternative decryption information image will have eight images corresponding to the eight kinds of offset positions, respectively. Based on the alternative decryption information images and the decryption information images obtained before, the plaintext corresponding to the accurate encryption information can be obtained by mutual comparison and reference.
It should be understood by those skilled in the art that the number and specific offset settings of the eight offset positions are exemplary, and that other data and offset positions are within the scope of the present application.
According to the embodiment, only the key used in encrypting information needs to be provided, the binary key image corresponding to the key and the encrypted information image generated after encryption can be based on the key, the decrypted information image can be obtained through fusion and superposition of the binary key image and the encrypted information image, and the original plaintext information can be obtained from the decrypted information image. The finally decrypted plaintext information can still be presented in the form of a visual image and is obtained through human eye identification, so that the problem of automatic and large-scale information leakage can be effectively avoided, and information safety in a scene that a physical entity is required to serve as an information presentation carrier is realized.
The data encryption method of the present embodiment may be performed by any suitable electronic device having data processing capabilities, including but not limited to: server, mobile terminal (such as mobile phone, PAD, etc.), PC, etc.
EXAMPLE III
In this embodiment, a list in a logistics express delivery scene is taken as an example, and the whole process of data encryption and data decryption is described with reference to fig. 4A and 4B.
As shown in fig. 4A, it shows a data encryption and decryption process according to the third embodiment of the present application, which includes the following steps:
step S402: the information to be encrypted is converted into an information image.
The specific process can comprise the following steps:
A) and acquiring information of a pre-constructed database.
In order to improve the security, a database is constructed, in which a large number of character information images and optionally images of graphic symbols are stored in a one-to-many manner. The database is in a one-to-many manner, that is, one information corresponds to a plurality of images, and characters or graphic symbols in the images can be visually recognized by human eyes and are regarded as corresponding information, but have great difference in shape.
B) And acquiring a character information image corresponding to the information to be encrypted from the database.
In this embodiment, taking the information to be encrypted as an example of characters, as shown in fig. 4B, the information to be encrypted is sensitive information "2795". Then, a character information image corresponding to each character in the information to be encrypted is obtained from the database, such as a character information image corresponding to "2", a character information image corresponding to "7", a character information image corresponding to "9", and a character information image corresponding to "5", respectively.
C) And uniformly performing binarization processing on all the character information images.
D) And sampling the character information image subjected to binarization processing, and unifying to a preset size.
The specific setting of the preset size can be set by those skilled in the art according to actual needs, and the embodiment of the present application does not limit this. If the size of the character information image is larger than the preset size, the character information image can be adjusted to the preset size through downsampling; if the size of the character information image is smaller than the preset size, the character information image can be adjusted to the preset size through upsampling.
D) And generating a graphical master plate with a corresponding size according to the size of the character information image with the uniform size, and reserving a certain space at four corners of the master plate for adding a positioning mark after the reserved space is reserved.
Since the four character information images of "2", "7", "9", "5" all have the same image width in the same size as in this example, a graphic master of the corresponding size can be generated based on the width and the total length of the four character information images.
E) And sequentially placing the obtained character information images in the graphical bottom plate according to the character sequence in the information to be encrypted, thereby generating a complete information image corresponding to the information to be encrypted.
As shown by patterned "2795" in fig. 4B.
Step S404: and encrypting the information image by using the binary key image corresponding to the key.
The specific process comprises the following steps:
F) a key is generated.
For example, a key seed (seed) may be employed to generate a binarization sequence of sufficient length. Illustrated in fig. 4B as being generated by a key generator. The generation of the key seed may be performed at any time before the encryption operation, either immediately before the encryption operation or before the imaging of the information to be encrypted in step S402 (i.e., the pre-key).
G) A binary key image is generated based on the key.
According to the size of the information image generated in step S402, the corresponding length is intercepted from the binarization sequence corresponding to the key, and converted into a binarization matrix of the same size, and then the binarization matrix is converted into a binarization key image. Such as the "binary key image" shown in fig. 4B.
H) And encrypting the information image.
The information image generated in step S402 and the binary key image are subjected to xor processing in sequence according to pixel positions, so as to obtain an encrypted information image, i.e., a ciphertext image, such as an "imaged ciphertext" shown in fig. 4B.
I) And adding a positioning mark.
For example, positioning marks with obvious features (as shown in the rectangular image block at the upper right corner in fig. 4B) are added at four corners of the encrypted information image, so as to generate a final encrypted information image which can be printed on the bill, as shown in the "materialized ciphertext" at the lower right corner in fig. 4B.
Step S406: and (5) restoring the encrypted information image.
Taking a bill as an example, the encrypted information image is finally printed on the bill for transmission, when decryption is performed, a decryption person firstly obtains an image of a corresponding area through modes such as photographing or scanning, and then performs a series of operations such as positioning, correcting and restoring on the image to obtain the corresponding encrypted information image, and the specific steps are as follows:
J) and acquiring an acquired image containing the completely encrypted information image area through image acquisition equipment.
K) And searching for a preset positioning mark in the encrypted information image in the acquired image to obtain four positioning coordinates A, B, C, D.
L) extracting a corresponding ciphertext image region according to the four positioning coordinate points, wherein the extracted ciphertext image region has a deformation problem due to the problems of physical deformation and shooting angles and may be non-rectangular. The ciphertext image area can be corrected to be rectangular through affine transformation according to the four positioning coordinates.
In the case where the size of the ciphertext image is available, the corrected rectangular image may be further transformed to the size corresponding to the ciphertext image.
M) reducing the image obtained in L) into a clean binary image through binarization processing.
The above process is simply illustrated as "reduction treatment" in fig. 4B.
Step S408: and decrypting the encrypted information image subjected to the restoration processing.
The key seed (seed) may be transmitted to the decrypter through a preset or secret channel, and the decrypter decrypts the restored simplex image by using the key. The key seed is the same as the key seed in step S404, and for security, the key seed may be preset on the device, and the encryption side and the decryption side unify the key; alternatively, the key seed may be updated or transferred on a regular basis to achieve greater security.
The decryption process may include:
and N) generating a binarization sequence through the key seeds, converting the binarization sequence into a binarization matrix and further converting into a binarization key image.
O) the encrypted information image obtained in step S406 and the binary key image are transformed to a uniform size.
And P) fusing and superposing the transformed encrypted information image and the binary key image.
The fusion and superposition mode comprises two modes, and can be realized by adopting any one of the two modes. Firstly, directly carrying out XOR operation on an encrypted information image and a binary key image according to pixel positions; secondly, simulating visual effect to carry out fusion and superposition, namely black blocks and black blocks are larger than black blocks; black blocks + white blocks- > black blocks; white block + white block — > white block.
Based on this, a decryption information image can be obtained, and illustratively, as shown by "decryption result" in fig. 4B, four characters of "2795" can be recognized by naked eyes in a form distinguished from a background.
However, if the "decrypted result" cannot clearly display the encrypted information, the following process Q may be optionally performed.
Q) generating an alternative decryption information image.
For example, the transformed encrypted information image is respectively shifted according to eight shift positions of [0, -1], [ -1,0], [ -1, -1], [0,1], [1,0], [1,1], [1, -1], [ -1,1] in sequence, and then respectively fused and superposed with the binary key image to generate a corresponding candidate decrypted image. By the mode, the dislocation phenomenon happened by the single-side image can be effectively resisted;
it can be seen that, through the above processes P) and Q), the decrypted information image obtained through the process P) can be presented to the decryptor, and the decryptor visually identifies the decrypted information content; if the information content is not clear enough, the decryptor can also choose to view the alternative decryption information image, in which case a plurality of alternative decryption information images can be presented to the decryptor at one time or in sequence.
According to the embodiment, the information to be encrypted is firstly imaged, and then the information content after imaging is protected by encrypting the binary key image. The encrypted information is still in the form of an image and can be printed on a receipt. Meanwhile, the encrypted key is also imaged, and key pre-positioning and one-key multi-purpose functions can be supported. The key corresponding to the face phase is passed to or prepended to the participant device that needs to decrypt the read information. The participant equipment obtains visual information content by scanning the encrypted information image on the menu and fusing the information image with the binary key image of the corresponding key. The participator obtains the information content through the visual identification of human eyes. Since the finally decrypted information is presented in the form of a visual image and is obtained in the form of human eye identification, the problem of automatic and large-scale information leakage can be effectively avoided. Because the encrypted information is presented in the form of an image in the bill, in order to reduce the problems of distortion and positioning caused by image scanning, the embodiment provides an automatic decoding scheme integrating image acquisition, positioning, restoration and fusion, thereby greatly improving the decryption efficiency and reducing the decryption cost.
Example four
Referring to fig. 5, a schematic structural diagram of an electronic device according to a fourth embodiment of the present application is shown, and the specific embodiment of the present application does not limit a specific implementation of the electronic device.
As shown in fig. 5, the electronic device may include: a processor (processor)502, a Communications Interface 504, a memory 506, and a communication bus 508.
Wherein:
the processor 502, communication interface 504, and memory 506 communicate with one another via a communication bus 508.
A communication interface 504 for communicating with other electronic devices or servers.
The processor 502 is configured to execute the program 510, and may specifically perform the relevant steps described in any one of the first to third embodiments of the method.
In particular, program 510 may include program code that includes computer operating instructions.
The processor 502 may be a CPU, or an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement embodiments of the present application. The intelligent device comprises one or more processors which can be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
And a memory 506 for storing a program 510. The memory 506 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 510 may be specifically configured to enable the processor 502 to execute operations corresponding to the method in any one of the first to third embodiments of the method.
For specific implementation of each step in the program 510, reference may be made to corresponding steps and corresponding descriptions in units in the foregoing method embodiments, and corresponding beneficial effects are provided, which are not described herein again. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described devices and modules may refer to the corresponding process descriptions in the foregoing method embodiments, and are not described herein again.
The embodiment of the present application further provides a computer program product, which includes computer instructions, where the computer instructions instruct a computing device to execute operations corresponding to any data encryption and decryption method in the foregoing multiple method embodiments.
It should be noted that, according to the implementation requirement, each component/step described in the embodiment of the present application may be divided into more components/steps, and two or more components/steps or partial operations of the components/steps may also be combined into a new component/step to achieve the purpose of the embodiment of the present application.
The above-described methods according to embodiments of the present application may be implemented in hardware, firmware, or as software or computer code storable in a recording medium such as a CD ROM, a RAM, a floppy disk, a hard disk, or a magneto-optical disk, or as computer code originally stored in a remote recording medium or a non-transitory machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the methods described herein may be stored in such software processes on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware such as an ASIC or FPGA. It is understood that a computer, processor, microprocessor controller, or programmable hardware includes memory components (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code that, when accessed and executed by a computer, processor, or hardware, implements the data encryption/decryption methods described herein. Further, when a general-purpose computer accesses code for implementing the data encryption/decryption method shown herein, execution of the code transforms the general-purpose computer into a special-purpose computer for performing the data encryption/decryption method shown herein.
Those of ordinary skill in the art will appreciate that the various illustrative elements and method steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
The above embodiments are only used for illustrating the embodiments of the present application, and not for limiting the embodiments of the present application, and those skilled in the relevant art can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application, so that all equivalent technical solutions also belong to the scope of the embodiments of the present application, and the scope of patent protection of the embodiments of the present application should be defined by the claims.

Claims (14)

1. A method of data encryption, comprising:
acquiring information to be encrypted and a key for encrypting the information to be encrypted;
converting information to be encrypted into an information image, and converting the key into a binary key image matched with the information image according to the size of the information image;
performing image fusion processing on the information image and the binary key image according to pixel positions;
and obtaining the encrypted information image according to the result of the image fusion processing.
2. The method according to claim 1, wherein said converting the key into a binarized key image matching the information image according to the size of the information image comprises:
acquiring a binary sequence corresponding to the secret key;
intercepting the binarization sequence according to the size of the information image to obtain a binarization matrix matched with the size of the information image;
and converting the binarization matrix into a binarization key image.
3. The method according to claim 1 or 2, wherein said converting the information to be encrypted into an information image comprises:
and acquiring each character in the information to be encrypted, and converting each character into a corresponding character information image.
4. The method of claim 3, wherein said converting each character into a corresponding character information image comprises:
inquiring and obtaining a plurality of character information images corresponding to each character from a database pre-stored with the character information images;
and aiming at each character, selecting a character information image from the corresponding character information images according to a preset rule as the character information image matched with the character.
5. The method of claim 3, wherein said converting each character into a corresponding character information image comprises:
and respectively carrying out binarization processing and uniform size processing on the character information image corresponding to each character to obtain a binarization character information image with uniform size corresponding to each character.
6. The method of claim 3, wherein the converting information to be encrypted into an information image comprises:
generating a graphical master for the information to be encrypted according to the size of a character information image corresponding to each character;
and according to the sequence of the characters in the information to be encrypted, placing a character information image corresponding to each character in the graphical master to generate an information image corresponding to the information to be encrypted.
7. The method of claim 6, wherein,
the image fusion processing of the information image and the binarization key image according to the pixel position comprises the following steps: according to the pixel position, carrying out pixel value exclusive OR processing on the information image and the binary key image;
the obtaining of the encrypted information image according to the result of the image fusion processing includes: and obtaining the encrypted information image according to the result of the exclusive-or processing.
8. A method of data decryption, comprising:
acquiring an encrypted information image carrying encrypted information and a binary key image generated based on a key, wherein the key is the same as an encryption key used by the encrypted information in the encrypted information image;
fusing and superposing the encrypted information image and the binary key image;
and acquiring a decryption information image corresponding to the encryption information image according to the fusion superposition result, wherein the decryption information image contains the plaintext of the encryption information.
9. The method according to claim 8, wherein said fusion superimposing said encrypted information image and said binarized key image comprises:
according to the pixel position, carrying out pixel value exclusive OR processing on the encrypted information image and the binary key image;
alternatively, the first and second electrodes may be,
and overlapping pixel blocks of the encrypted information image and the binarization key image according to the preset pixel block size and the preset pixel position.
10. The method according to claims 8 and 9, wherein the method further comprises:
carrying out offset operation on the encrypted information image according to a preset offset position;
and fusing and superposing the encrypted information image subjected to the offset operation and the binary key image to obtain an alternative decrypted information image corresponding to the offset position, wherein the alternative decrypted information image comprises plaintext information corresponding to the encrypted information.
11. The method according to claims 8 and 9, wherein the obtaining of the encrypted information image carrying the encrypted information and the binarized key image generated based on the key comprises:
acquiring an encrypted information image carrying encrypted information;
acquiring a binarization sequence corresponding to a secret key, and intercepting the binarization sequence according to the size of the encrypted information image to obtain a binarization matrix matched with the size of the encrypted information image;
and converting the binarization matrix into a binarization key image.
12. The method according to claims 8 and 9, wherein the obtaining of the encrypted information image carrying the encrypted information comprises:
acquiring an image of the entity bearing the encrypted information image to obtain an acquired image containing the encrypted information image;
and determining a positioning mark from the acquired image, and obtaining the encrypted information image according to the positioning mark.
13. The method of claim 12, wherein said obtaining the encrypted information image from the positioning marker comprises:
obtaining an information image area according to the positioning mark;
carrying out affine transformation on the information image area;
and carrying out binarization processing on the information image area subjected to affine transformation to obtain the encrypted information image.
14. A computer storage medium having stored thereon a computer program which, when executed by a processor, implements a data encryption method as claimed in any one of claims 1 to 7, or implements a data decryption method as claimed in any one of claims 8 to 13.
CN202111347955.0A 2021-11-15 2021-11-15 Data encryption and decryption method and computer storage medium Pending CN114036542A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111347955.0A CN114036542A (en) 2021-11-15 2021-11-15 Data encryption and decryption method and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111347955.0A CN114036542A (en) 2021-11-15 2021-11-15 Data encryption and decryption method and computer storage medium

Publications (1)

Publication Number Publication Date
CN114036542A true CN114036542A (en) 2022-02-11

Family

ID=80144406

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111347955.0A Pending CN114036542A (en) 2021-11-15 2021-11-15 Data encryption and decryption method and computer storage medium

Country Status (1)

Country Link
CN (1) CN114036542A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114745109A (en) * 2022-04-06 2022-07-12 国网浙江省电力有限公司宁波供电公司 Power distribution terminal encryption communication system and method based on quantum encryption
CN115361237A (en) * 2022-10-20 2022-11-18 北京国旺盛源智能终端科技有限公司 Data encryption transmission method and system for cloud terminal interaction
CN115834791A (en) * 2023-02-03 2023-03-21 徐工汉云技术股份有限公司 Image encryption and decryption transmission method using matrix key and electronic equipment
CN115834790A (en) * 2023-01-09 2023-03-21 徐工汉云技术股份有限公司 Information encryption transmission method and information decryption transmission method based on pixel movement

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114745109A (en) * 2022-04-06 2022-07-12 国网浙江省电力有限公司宁波供电公司 Power distribution terminal encryption communication system and method based on quantum encryption
CN115361237A (en) * 2022-10-20 2022-11-18 北京国旺盛源智能终端科技有限公司 Data encryption transmission method and system for cloud terminal interaction
CN115361237B (en) * 2022-10-20 2022-12-16 北京国旺盛源智能终端科技有限公司 Data encryption transmission method and system for cloud terminal interaction
CN115834790A (en) * 2023-01-09 2023-03-21 徐工汉云技术股份有限公司 Information encryption transmission method and information decryption transmission method based on pixel movement
CN115834791A (en) * 2023-02-03 2023-03-21 徐工汉云技术股份有限公司 Image encryption and decryption transmission method using matrix key and electronic equipment

Similar Documents

Publication Publication Date Title
CN114036542A (en) Data encryption and decryption method and computer storage medium
US20030048908A1 (en) System and method for protecting the content of digital cinema products
JP2005515500A (en) Secure data entry dialog using visual encryption
US20190363876A1 (en) Methods and Apparatus for Cryptography
CN107579903B (en) Picture message secure transmission method and system based on mobile device
WO2015058658A1 (en) Text encryption and interaction method, encryption method and apparatus, and decryption method and apparatus
CN109348230A (en) A kind of ciphertext domain high capacity image reversible data concealing method
CN110135177A (en) Asymmetric image encryption and authentication method and device
US20220284448A1 (en) Anti-counterfeiting and encryption method based on local random image transformation technique
WO2004054167A1 (en) System and method for the exchange of cryptographic keys
CN105447404A (en) Method and system for protecting image privacy in cloud storage
CN113297613A (en) Key access method, key processing device, key processing equipment and computer storage medium
US11558375B1 (en) Password protection with independent virtual keyboard
CN109379351B (en) Two-dimensional code encryption method, storage medium, equipment and system
Sazaki et al. Implementation of affine transform method and advanced hill cipher for securing digital images
US20160189015A1 (en) Data exchange methods, systems and apparatus using color images
CN107689867B (en) Key protection method and system under open environment
CN112637442B (en) Method and device for encrypting circulating images by cloud server and local end
CN104702814A (en) Method for separately storing and recovering (K, N) meaningful images based on triple backup
CN111131270B (en) Data encryption and decryption method and device, electronic equipment and storage medium
TWI667591B (en) Method for safely transferring pictures
WO2016094978A1 (en) Method for recovering secrets encrypted with visual cryptography by automatic alignment in mobile devices
KR20210045823A (en) Apparatus and method for securing document information
KR101746577B1 (en) System and Method for Authenticating a user using Visualize Password and Authentication Sever
CN115225771B (en) Method and device for hiding reversible information of encrypted image and computer equipment

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