CN113810189B - Method and device for generating key picture - Google Patents

Method and device for generating key picture Download PDF

Info

Publication number
CN113810189B
CN113810189B CN202111254202.5A CN202111254202A CN113810189B CN 113810189 B CN113810189 B CN 113810189B CN 202111254202 A CN202111254202 A CN 202111254202A CN 113810189 B CN113810189 B CN 113810189B
Authority
CN
China
Prior art keywords
picture
key
length
preset
encryption 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.)
Active
Application number
CN202111254202.5A
Other languages
Chinese (zh)
Other versions
CN113810189A (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.)
Zhongdian Jinxin Software Co Ltd
Original Assignee
Zhongdian Jinxin Software 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 Zhongdian Jinxin Software Co Ltd filed Critical Zhongdian Jinxin Software Co Ltd
Priority to CN202111254202.5A priority Critical patent/CN113810189B/en
Publication of CN113810189A publication Critical patent/CN113810189A/en
Application granted granted Critical
Publication of CN113810189B publication Critical patent/CN113810189B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0894Escrow, recovery or storing of secret information, e.g. secret key escrow or cryptographic key storage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/40Filling a planar surface by adding surface attributes, e.g. colour or texture
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0618Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
    • H04L9/0631Substitution permutation network [SPN], i.e. cipher composed of a number of stages or rounds each involving linear and nonlinear transformations, e.g. AES algorithms

Abstract

The embodiment of the application provides a method and a device for generating a key picture, which relate to the field of data encryption, wherein the method for generating the key picture comprises the following steps: calculating according to the character string length value of the encryption key and a preset picture size calculation formula to obtain a picture length and a picture width; obtaining a conventional picture according to the determined size of the picture length and the picture width; respectively determining target three primary colors from three primary colors corresponding to each pixel in a conventional picture; determining a target value from binary values corresponding to the target three primary colors; and sequentially replacing the target values with binary values respectively corresponding to the encryption key and the character string length value to obtain a key picture. It can be seen that by implementing this embodiment, a new encryption key storage mode can be created, so that the security of information is ensured.

Description

Method and device for generating key picture
Technical Field
The present invention relates to the field of data encryption, and in particular, to a method and an apparatus for generating a key picture.
Background
In order to ensure information security between the client and the server, encryption is generally adopted to improve information security. However, the encryption key is inevitably generated by this encryption method. This has the effect that the encryption key has to be carefully stored by the client in order to avoid leakage.
However, in practice, it is found that the current encryption key storage mode is usually a storage mode such as code plaintext storage and application configuration file storage. The storage modes can be acquired by other people through code inquiry means. Therefore, the encryption key storage mode greatly reduces the safety of the information, so that the technical effect of guaranteeing the safety of the information cannot be realized.
Disclosure of Invention
The embodiment of the application aims to provide a method and a device for generating a key picture, which can create a new encryption key storage mode so as to ensure the safety of information.
An embodiment of the present application provides a method for generating a key picture, including:
calculating according to the character string length value of the encryption key and a preset picture size calculation formula to obtain a picture length and a picture width;
obtaining a conventional picture according to the size determined by the picture length and the picture width;
respectively determining target three primary colors from three primary colors corresponding to each pixel in the conventional picture;
determining a target value from binary values corresponding to the target three primary colors;
and sequentially replacing the target values with binary values respectively corresponding to the encryption key and the character string length value to obtain a key picture.
In the implementation process, the method can encrypt the file to be encrypted according to the actual encryption requirement to obtain the encryption key, then match the corresponding conventional picture according to the encryption key, and finally write the key length of the encryption key and the encryption key into the conventional picture, thereby realizing the picture storage process of the encryption key and further obtaining a key picture comprising key information. It can be seen that implementing this embodiment can hide the encryption key in the picture, so that the key can be prevented from being directly acquired; on the other hand, by implementing the embodiment, the picture can be used as a key carrier, so that the possibility of identifying the key is reduced, and the safety of the information is effectively ensured.
Further, the step of calculating according to the character string length value of the encryption key and a preset picture size calculation formula to obtain the picture length and the picture width includes:
calculating according to the character string length value of the encryption key, the preset character storage digit and the preset length value storage digit to obtain the picture length and the picture width; the character storage bit number is used for expressing the number of pixels required for storing a single character; the length value storage bit number is used for expressing the number of pixels required for storing the character string length value.
Further, the step of calculating according to the character string length value of the encryption key and a preset picture size calculation formula to obtain the picture length and the picture width includes:
calculating according to the character string length value, the preset character storage digit and the preset length value storage digit of the encryption key to obtain an initial length and an initial width;
taking the sum of the initial length and the preset first pixel number as a picture length; and taking the sum of the initial width and the preset second pixel number as the picture width.
Further, the preset picture size calculation formula is:
wherein px is a pixel unit;
the 8 (px) is the number of bits of the character storage;
the 32 (px) is the length value storage digit;
the a (px) is the first pixel number;
and b (px) is the second pixel number.
Further, the step of obtaining a conventional picture according to the size determined by the picture length and the picture width includes:
and according to a preset color base and the size determined by the length and the width of the picture, obtaining a conventional picture.
Further, the step of determining the target value from the binary values corresponding to the target three primary colors includes:
and taking one bit with the lowest bit number in binary values corresponding to the target three primary colors as a target value.
Further, the step of replacing the target value with binary values respectively corresponding to the encryption key and the character string length value in sequence to obtain a key picture includes:
determining a current value from binary values respectively corresponding to the encryption key and the character string length;
determining a current pixel from the conventional picture in the order from left to right and from top to bottom;
and replacing the target value in the current pixel with the current value to obtain a key picture.
Further, the picture length is equal to the picture width.
A second aspect of the embodiments of the present application provides a key picture generating device, where the key picture generating device includes:
the computing unit is used for computing according to the character string length value of the encryption key and a preset picture size computing formula to obtain a picture length and a picture width;
the acquisition unit is used for acquiring a conventional picture according to the size determined by the picture length and the picture width;
a determining unit, configured to determine a target three primary colors from three primary colors corresponding to each pixel in the conventional picture, respectively;
the determining unit is further used for determining a target value from binary values corresponding to the target three primary colors;
and the replacing unit is used for sequentially replacing the target values with binary values respectively corresponding to the encryption key and the character string length value to obtain a key picture.
In the implementation process, the device can hide the encryption key in the picture, so that the key can be prevented from being directly acquired; on the other hand, the device can also take the picture as a secret key carrier, so that the possibility that the secret key is identified is reduced, and the safety of information is further effectively ensured.
A third aspect of the embodiments of the present application provides an electronic device, including a memory and a processor, where the memory is configured to store a computer program, and the processor is configured to execute the computer program to cause the electronic device to execute the method for generating a key picture according to any one of the first aspect of the embodiments of the present application.
A fourth aspect of the embodiments of the present application provides a computer readable storage medium storing computer program instructions that, when read and executed by a processor, perform the method for generating a key picture according to any one of the first aspect of the embodiments of the present application.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for generating a key picture according to an embodiment of the present application;
fig. 2 is a flowchart of another key picture generation method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a key picture generating device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of another key picture generating device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only to distinguish the description, and are not to be construed as indicating or implying relative importance.
Example 1
Referring to fig. 1, fig. 1 is a flowchart of a method for generating a key picture according to an embodiment of the present application. The key picture generation method comprises the following steps:
s101, calculating according to a character string length value of the encryption key and a preset picture size calculation formula to obtain a picture length and a picture width.
As an optional implementation manner, before the step of calculating according to the character string length value of the encryption key and the preset picture size calculation formula to obtain the picture length and the picture width, the method further includes:
an encryption key is generated.
In this embodiment, the method may preferentially detect the project requirement, and encrypt the requirement point when the project requirement includes the security requirement, so as to obtain the encryption key.
In this embodiment, the method may encrypt the data to be encrypted according to a preset encryption algorithm to obtain an encryption key; the encryption algorithm includes at least one or more of DES, AES, 3DES, RSA, DSA, and ECC.
In this embodiment, the picture length may be equal to the picture width. It can be seen that this arrangement facilitates the calculation of the picture length and/or the picture width.
In this embodiment, the picture length and the picture width may be the picture size. It can be seen that the picture size calculation formula is a calculation formula for calculating a picture length or a picture width.
S102, obtaining a conventional picture according to the size determined by the picture length and the picture width.
In this embodiment, the method uses a JAVA language image API to generate a regular picture that matches the picture length and/or picture width.
In this embodiment, a regular picture is used to store the encryption key.
In this embodiment, the conventional picture may be a PNG-format picture, a JPG-format picture, or a JPEG-format picture. Such conventional pictures should also typically have the property of being compression lossless.
S103, respectively determining target three primary colors from the three primary colors corresponding to each pixel in the conventional picture.
In this embodiment, the three primary colors are RGB three primary colors.
In this embodiment, the target three primary colors are one of the RGB three primary colors, which may be red, green, or blue.
S104, determining a target value from binary values corresponding to the target three primary colors.
In this embodiment, since the RGB three primary colors of each pixel have a value of 0 to 255, the value corresponds to 8-bit binary, and the target value is one bit of the 8-bit binary.
In this embodiment, the target value is preferably the least significant bit in the 8-bit binary system described above.
S105, sequentially replacing target values with binary values respectively corresponding to the encryption key and the character string length value to obtain a key picture.
By implementing this embodiment, a key picture can be generated so that the key picture stores the encryption key. When the encryption key is stored in the conventional picture, the method can modify the least significant pixel bits of the conventional picture so as to store the encryption key in the key picture in a hidden manner. The process of hiding the encryption key in the picture will not destroy the conventional picture. Thus, when a key picture is placed anywhere in the client or the background, it is easily not guessed by a person to obtain. When the encryption key is to be read, it is also only necessary to read the encryption key in the same read-write order as the encryption order. The writing sequence of the encryption key is automatically controllable, and the key picture can be prevented from being obtained by guessing by people, so that the method can improve the application safety of the encryption key.
In this embodiment, the placement of the key picture anywhere in the client or the background means that the picture is manually placed under a mobile terminal development project capable of storing a resource directory, for example: and (5) downloading resource directories such as assets, res and the like. The only limitation of the memory directory is that the key picture can be loaded into the program and read during the program operation.
In this embodiment, according to the actual situation, the server generally encrypts data, and the client receives the encrypted data and decrypts the encrypted data according to the encryption key. The execution main body of the method is the server.
In this embodiment, the client places the generated key picture on the client, and reads the encryption key from the key picture in the reverse direction in the manner of generating the key picture when the client is started.
In this embodiment of the present application, the execution subject of the method may be a computing device such as a computer or a server, which is not limited in this embodiment.
In this embodiment of the present application, the execution body of the method may also be an intelligent device such as a smart phone, a tablet computer, and the like, which is not limited in this embodiment.
Therefore, by implementing the method for generating the key picture described in the embodiment, the file to be encrypted can be encrypted according to the actual encryption requirement to obtain the encryption key, then the corresponding conventional picture is matched according to the encryption key, and finally the key length of the encryption key and the encryption key are written into the conventional picture, so that the picture storage process of the encryption key is realized, and a key picture including key information is obtained. It can be seen that implementing this embodiment can hide the encryption key in the picture, so that the key can be prevented from being directly acquired; on the other hand, by implementing the embodiment, the picture can be used as a key carrier, so that the possibility of identifying the key is reduced, and the safety of the information is effectively ensured.
Example 2
Referring to fig. 2, fig. 2 is a flowchart of a method for generating a key picture according to an embodiment of the present application. As shown in fig. 2, the method for generating the key picture includes:
s201, encrypting the data to be encrypted according to a preset encryption algorithm to obtain an encryption key.
In this embodiment, the data to be encrypted is data to be encrypted.
In this embodiment, the encryption key is generated by the server according to an encryption algorithm. Typically, the server has an API that generates random keys. The encryption key is generally displayed in a form of a string of texts, and acts like a codebook.
If the DES algorithm is adopted, the related API adopting the DES can generate a symmetric key, and the key is randomly generated
In this embodiment, the encryption algorithm includes at least one or more of DES, AES, 3DES, RSA, DSA, and ECC.
In this embodiment, the encryption algorithm may be a symmetric encryption algorithm or an asymmetric encryption algorithm, which is not limited in this embodiment.
S202, calculating according to a character string length value of an encryption key, a preset character storage digit and a preset length value storage digit to obtain a picture length and a picture width; the character storage bit number is used for expressing the number of pixels required for storing a single character; the length value storage bit number is used to express the number of pixels required for storing the length value of the substring.
S203, calculating according to the character string length value, the preset character storage digit and the preset length value storage digit to obtain an initial length and an initial width.
In this embodiment, the initial length and the initial width may constitute a key storage area. The key storage area is the minimum area required to store keys.
For example, storing hello, which requires 5*8 =40 pixels, plus 32 pixels for storing the string key length value "5", results in 40+32=72 pixels,for the initial length +.>Also the initial width. Here, the initial length is equal to the initial width.
S204, taking the sum of the initial length and the preset first pixel number as the picture length; taking the sum of the initial width and the preset number of the second pixels as the picture width.
In this embodiment, the preset picture size calculation formula is as follows:
wherein px is a pixel unit;
8 (px) is the number of bits for storing the character;
32 (px) is the length value storage digit;
a (px) is the first pixel number;
b (px) is the second pixel number.
In this embodiment, the steps S202 to S204 may be calculated by the formula.
In this embodiment, the first pixel number and the second pixel number may be the same, that is, a=b.
In this embodiment, when a and/or b are not zero, it is indicated that the picture length and/or the picture width are not the minimum length and/or the minimum width. Therefore, the calculation result can have the additional expansion area for the finally obtained picture, so that the encryption key and the character string length value can be effectively stored. Meanwhile, the generation of the expansion area can also avoid adjusting all pixels, so that the adjusted pixels and unadjusted pixels in the encrypted picture are ensured, and the credibility of the encrypted picture is further improved.
In this embodiment, the first pixel number and/or the second pixel number is a capacity-expanded pixel value. For a picture, the value of the expansion pixel exists in both the horizontal and vertical directions of the picture. For example, when the number of the first pixels and the number of the second pixels are both 10 pixels, at least 100 pixels are used as the expansion area. Therefore, the problem of overflow generated when data are written due to insufficient pixel space of the picture can be effectively prevented, and the situation that the writing of the encryption key fails is avoided.
In this embodiment, assuming that the length is x pixels and the width is y pixels when the first pixel number and the second pixel number are not added to the conventional picture, the area of the expansion area should be [ (10×x) + (10×y) +100] pixels.
For example, when the encryption key is "hello", the string length value is 5. At this time, the calculation is performed, and the picture size is obtained (this calculation mode uses a round-down calculation logic). Therefore, in the process, the picture length and the picture width can be calculated to be 18px. Accordingly, the conventional picture should be a 18px x 18px picture, and the format may be PNG format.
In this embodiment, the reason why the length value storage bit number is 32 pixels is as follows:
a. the reading of 32 pixels in the reading link is convenient, and the number of pixels to be read in the follow-up process, namely the length of the follow-up process, can be known;
b. 32 pixels are used because the length is of the int type in java, 4 bytes (byte) are occupied, and according to the conversion of 8 bits (bits) per byte, 32 bits are needed, whereas modifying one of the channels in the present invention is equivalent to modifying one of the valid bits, such as length 5 of "hello".
c. The selection of 64 and 128 is unnecessary, the picture space is wasted, the picture is enlarged, and the larger the picture is at the mobile end, the larger the occupied memory is needed in the running period of the loading device, so that the user can 32
S205, according to a preset color base, regulating the size determined by the length and the width of the picture to obtain a conventional picture.
In this embodiment, the color key includes gray, red, blue, green, and the like.
In this embodiment, when the method uses colors of gray, brown, black, etc., the viewer is more hard to see because the color of the picture is darker. Thus, the confidentiality of the key picture can be considered higher when the viewer does not see it clearly.
On the other hand, when the method uses red, green and blue colors, as each pixel is composed of RGB three colors, when a specific color channel corresponding to a color basic tone is selected, the change of the least significant bit of the pixel becomes finer, thereby effectively improving the confidentiality of the key picture.
In this embodiment, the format of the conventional picture may be PNG format, JPG format, or the like.
In this embodiment, a Java image API is used to generate a picture having a size corresponding to a color key, a picture length, and a picture width.
For example, the method may generate an 18 x 18 gray-tone PNG picture.
S206, respectively determining target three primary colors from the three primary colors corresponding to each pixel in the conventional picture.
S207, taking one bit with the lowest bit number of binary values corresponding to the target three primary colors as a target value.
S208, sequentially replacing target values with binary values respectively corresponding to the encryption key and the character string length value to obtain a key picture.
S209, determining the current value from binary values respectively corresponding to the encryption key and the character string length.
S210, determining the current pixel from the conventional picture in the order from left to right and from top to bottom.
In this embodiment, the picture is generally composed of a plurality of pixels, wherein the pixel arrangement is generally regular, i.e. how many rows and how many columns are arranged.
In this embodiment, the key writing order may be an order of first from left to right and then from top to bottom among the plurality of pixels. The present embodiment is not limited to this writing sequence.
In this embodiment, the method uses the horizontal axis of the conventional picture as the width direction and the vertical axis as the height direction. The "horizontal axis direction, left-right, top-down order" means a manner of first the horizontal axis and then the vertical axis, and each time the horizontal axis is written with a full line (the boundary is the picture width pixel size), then the writing is continued from the second line, and each time the writing is completed, the writing of the remaining data is automatically continued from the next line until all the data is completed.
S211, replacing the target value in the current pixel with the current value to obtain the key picture.
In this embodiment, the color of each pixel is composed of three primary colors (red, green and blue), so that each pixel color in the computer has three color channels, each channel occupies 8 bits, and takes a value of 0x00 to 0xFF (i.e., each channel can represent 0 to 256 colors), and three channels can represent 256 x 256 colors.
For example, RGB of the wine red "#a6479" are (166, 77, 121), respectively, and the actual expression is in the computer:
RED:10100110 (from left to right, the number of bits goes from high to low, where the least significant bit is 0);
GREEN:01001101 (from left to right, the number of bits is from high to low, where the least significant bit is 1);
BLUE:01111001 (from left to right, the number of bits is from high to low, where the least significant bit is 1);
namely: 10100110 01001101, 01111001 have three least significant bits, 0,1 respectively, and the method uses a way to modify the least significant bit of only one of the channels (blue channel).
In this embodiment, the method may write the encryption key to the least significant bit of the blue channel in each pixel, so that the least significant bit of the blue channel of 8 pixels may form a character.
In this embodiment, since the modification of the least significant bit is not visible to the naked human eye, the purpose of hiding the data can be achieved. For example, a red picture is modified by me to modify the least significant bit of one pixel point, but the whole human feel is still red and is not easy to perceive. The reason for not choosing other valid bits is similar to the above, because the modified stable high bits are more easily perceived than the modified low bits.
For example, when the encryption key is "hello", the data binary written in the picture is expressed as: the string length value of the encryption key is:
[0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
the encryption key is:
[0,1,1,0,1,0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1]。
for example, when the writing sequence is in the first horizontal axis direction, writing is started from the first pixel from left to right, the key length of the encryption key is written in the first 32 pixels, then writing of the encryption key data is started from 32 pixels until the data is written, wherein each line is written in full, and the writing is started from the next line from left to right automatically. Such as: writing "hello" as an encryption key into an 18 x 18 picture (the size of which is calculated as described above in the example), the pixel boundaries are:
width w= [0-18] px height h= [0-18] px;
the string length value 5 is converted into binary data as follows:
0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
picture line 1:
line 1: px (0, 0) =w. (0), h (0) to px (17, 0) =w. (17), the data inserted during h (0) are:
0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0;
line 2: px (0, 1) =w. (0), h (1) to px (17, 1) =w. (17), and the data inserted during h (1) are:
0, x (-) -A/D (-) -A/D where x represents the subsequent position);
the text data is converted into binary data:
0,1,1,0,1,0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1;
the data written by the text data may start from px (14, 1), i.e. the x position mentioned above, and subsequent data is written.
Therefore, by implementing the method for generating the key picture described in the embodiment, a manner of storing the encryption key in the key picture can be provided, so that the application security of the key picture is improved. Specifically, the method writes the encryption key into the least significant bit of the conventional image, and writes the encryption key into the conventional image sequentially from left to right and then from top to bottom in the horizontal axis direction of the image. The first 32 pixels are used as a storage area with a key length, and the subsequent pixels are used as encryption key storage areas, so that all key information is stored in the picture. When reading, only the reading sequence consistent with the writing sequence is needed to be selected, the key length can be read first, then the encryption key is read according to the key length, and further the extraction operation of the encryption key is completed.
Example 3
Referring to fig. 3, fig. 3 is a schematic structural diagram of a key picture generating device according to an embodiment of the present application. As shown in fig. 3, the key picture generation apparatus includes:
a calculating unit 310, configured to calculate according to the string length value of the encryption key and a preset picture size calculation formula, to obtain a picture length and a picture width;
an obtaining unit 320, configured to obtain a conventional picture according to the size determined by the picture length and the picture width;
a determining unit 330, configured to determine a target three primary colors from the three primary colors corresponding to each pixel in the regular picture, respectively;
the determining unit 330 is further configured to determine a target value from binary values corresponding to the target three primary colors;
and a replacing unit 340, configured to replace the target values with binary values respectively corresponding to the encryption key and the string length value in sequence, so as to obtain a key picture.
In this embodiment of the present application, the explanation of the key picture generating device may refer to the description in embodiment 1 or embodiment 2, and no redundant description is given in this embodiment.
Therefore, the generation device of the key picture described in the embodiment can hide the encryption key in the picture, so as to avoid the key from being directly acquired; on the other hand, the device can also take the picture as a secret key carrier, so that the possibility that the secret key is identified is reduced, and the safety of information is further effectively ensured.
Example 4
Referring to fig. 4, fig. 4 is a schematic structural diagram of a key picture generating device according to an embodiment of the present application. The key picture generating device shown in fig. 4 is optimized by the key picture generating device shown in fig. 3. As shown in fig. 4, the calculating unit 310 is specifically configured to calculate according to the string length value of the encryption key, the preset number of storage bits of the string length value, and the preset number of storage bits of the string length value, so as to obtain a picture length and a picture width; the character storage bit number is used for expressing the number of pixels required for storing a single character; the length value storage bit number is used to express the number of pixels required for storing the length value of the substring.
As an optional implementation manner, the calculating unit 310 is specifically further configured to calculate according to the string length value of the encryption key, the preset number of storage bits of the character, and the preset number of storage bits of the length value, so as to obtain an initial length and an initial width; taking the sum of the initial length and the preset first pixel number as the picture length; taking the sum of the initial width and the preset number of the second pixels as the picture width.
As an alternative embodiment, the preset picture size calculation formula is:
wherein px is a pixel unit;
8 (px) is the number of bits for storing the character;
32 (px) is the length value storage digit;
a (px) is the first pixel number;
b (px) is the second pixel number.
As an alternative embodiment, the obtaining unit 320 is specifically configured to obtain a conventional picture according to a preset color base and a size determined by a picture length and a picture width.
As an alternative embodiment, the determining unit 330 is specifically configured to take, as the target value, a bit with the lowest number of bits of the binary values corresponding to the target three primary colors.
As an alternative embodiment, the replacing unit 340 includes:
a determining subunit 341, configured to determine a current value from binary values respectively corresponding to the encryption key and the string length;
a determining subunit 341, configured to determine, from the conventional picture, a current pixel in order from left to right and from top to bottom;
a replacing subunit 342, configured to replace the target value in the current pixel with the current value, to obtain the key picture.
In this embodiment, the encryption key may be obtained by encrypting the data to be encrypted according to a preset encryption algorithm; the encryption algorithm includes at least one or more of DES, AES, 3DES, RSA, DSA, and ECC.
As an alternative embodiment, the picture length is equal to the picture width.
In this embodiment of the present application, the explanation of the key picture generating device may refer to the description in embodiment 1 or embodiment 2, and no redundant description is given in this embodiment.
Therefore, the generation device of the key picture described in the embodiment can hide the encryption key in the picture, so as to avoid the key from being directly acquired; on the other hand, the device can also take the picture as a secret key carrier, so that the possibility that the secret key is identified is reduced, and the safety of information is further effectively ensured.
The embodiment of the application provides an electronic device, which comprises a memory and a processor, wherein the memory is used for storing a computer program, and the processor runs the computer program to enable the electronic device to execute the generation method of the key picture in any one of the embodiment 1 or the embodiment 2 of the application.
The present embodiment provides a computer readable storage medium storing computer program instructions that, when read and executed by a processor, perform the method for generating a key picture according to any one of embodiment 1 or embodiment 2 of the present application.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners as well. The apparatus embodiments described above are merely illustrative, for example, flow diagrams and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely exemplary embodiments of the present application and is not intended to limit the scope of the present application, and various modifications and variations may be suggested to one skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application. It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Claims (7)

1. A method for generating a key picture, comprising:
calculating according to the character string length value of the encryption key and a preset picture size calculation formula to obtain a picture length and a picture width;
obtaining a conventional picture according to the size determined by the picture length and the picture width;
respectively determining target three primary colors from three primary colors corresponding to each pixel in the conventional picture;
determining a target value from binary values corresponding to the target three primary colors;
sequentially replacing the target values with binary values respectively corresponding to the encryption key and the character string length value to obtain a key picture;
the step of calculating according to the length value of the character string of the encryption key and a preset picture size calculation formula to obtain the picture length and the picture width comprises the following steps:
calculating according to the character string length value of the encryption key, the preset character storage digit and the preset length value storage digit to obtain the picture length and the picture width; the character storage bit number is used for expressing the number of pixels required for storing a single character; the length value storage bit number is used for expressing the number of pixels required for storing the character string length value;
the step of calculating according to the character string length value of the encryption key and a preset picture size calculation formula to obtain the picture length and the picture width comprises the following steps:
calculating according to the character string length value, the preset character storage digit and the preset length value storage digit of the encryption key to obtain an initial length and an initial width;
taking the sum of the initial length and the preset first pixel number as a picture length; taking the sum of the initial width and the number of the preset second pixels as a picture width;
the preset picture size calculation formula is as follows:
wherein px is a pixel unit;
the 8 (px) is the number of bits of the character storage;
the 32 (px) is the length value storage digit;
the a (px) is the first pixel number;
and b (px) is the second pixel number.
2. The method for generating a key picture according to claim 1, wherein the step of obtaining a regular picture according to the size determined by the picture length and the picture width comprises:
and according to a preset color base and the size determined by the length and the width of the picture, obtaining a conventional picture.
3. The key picture generation method according to claim 1, wherein the step of determining the target value from binary values corresponding to the target three primary colors includes:
and taking one bit with the lowest bit number in binary values corresponding to the target three primary colors as a target value.
4. The key picture generation method according to claim 3, wherein the step of replacing the target value with binary values respectively corresponding to the encryption key and the character string length value in sequence to obtain the key picture comprises:
determining a current value from binary values respectively corresponding to the encryption key and the character string length;
determining a current pixel from the conventional picture in the order from left to right and from top to bottom;
and replacing the target value in the current pixel with the current value to obtain a key picture.
5. A key picture generation apparatus, characterized in that the key picture generation apparatus includes:
the computing unit is used for computing according to the character string length value of the encryption key and a preset picture size computing formula to obtain a picture length and a picture width;
the acquisition unit is used for acquiring a conventional picture according to the size determined by the picture length and the picture width;
a determining unit, configured to determine a target three primary colors from three primary colors corresponding to each pixel in the conventional picture, respectively;
the determining unit is further used for determining a target value from binary values corresponding to the target three primary colors;
a replacing unit, configured to replace the target values sequentially with binary values corresponding to the encryption key and the string length value, to obtain a key picture;
the computing unit is specifically configured to perform computation according to a character string length value of the encryption key, a preset character storage bit number and a preset length value storage bit number to obtain a picture length and a picture width; the character storage bit number is used for expressing the number of pixels required for storing a single character; the length value storage bit number is used for expressing the number of pixels required for storing the length value of the substring;
the computing unit is specifically configured to perform computation according to a string length value of the encryption key, a preset character storage bit number, and a preset length value storage bit number, so as to obtain an initial length and an initial width; taking the sum of the initial length and the preset first pixel number as the picture length; taking the sum of the initial width and the preset number of the second pixels as the picture width;
the preset picture size calculation formula is as follows:
wherein px is a pixel unit;
8 (px) is the number of bits for storing the character;
32 (px) is the length value storage digit;
a (px) is the first pixel number;
b (px) is the second pixel number.
6. An electronic device comprising a memory for storing a computer program and a processor that runs the computer program to cause the electronic device to perform the method of generating a key picture as claimed in any one of claims 1 to 4.
7. A readable storage medium, wherein computer program instructions are stored in the readable storage medium, which when read and executed by a processor, perform the method of generating a key picture according to any one of claims 1 to 4.
CN202111254202.5A 2021-10-27 2021-10-27 Method and device for generating key picture Active CN113810189B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111254202.5A CN113810189B (en) 2021-10-27 2021-10-27 Method and device for generating key picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111254202.5A CN113810189B (en) 2021-10-27 2021-10-27 Method and device for generating key picture

Publications (2)

Publication Number Publication Date
CN113810189A CN113810189A (en) 2021-12-17
CN113810189B true CN113810189B (en) 2024-01-09

Family

ID=78937876

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111254202.5A Active CN113810189B (en) 2021-10-27 2021-10-27 Method and device for generating key picture

Country Status (1)

Country Link
CN (1) CN113810189B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114448687A (en) * 2022-01-18 2022-05-06 徐工汉云技术股份有限公司 Image file encryption method and system based on RSA

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013258488A (en) * 2012-06-11 2013-12-26 Osaka Gas Co Ltd Encryption key generation system and authentication system
WO2017124940A1 (en) * 2016-01-21 2017-07-27 腾讯科技(深圳)有限公司 Method and device for recognizing whether image comprises watermark
CN107481181A (en) * 2017-07-27 2017-12-15 银江股份有限公司 A kind of picture hidden method, restoring method and picture for being used to protect individual privacy hides system
CN110321673A (en) * 2018-03-28 2019-10-11 北京京东尚科信息技术有限公司 Information ciphering method and device, information decryption method and device, security system
CN110516462A (en) * 2019-08-30 2019-11-29 京东数字科技控股有限公司 Method and apparatus for encryption data
CN111079189A (en) * 2019-12-30 2020-04-28 联想(北京)有限公司 Information processing method, electronic equipment and computer readable storage medium
CN111898142A (en) * 2020-07-16 2020-11-06 常州工学院 Password hiding and inquiring method based on picture
WO2020237868A1 (en) * 2019-05-24 2020-12-03 平安科技(深圳)有限公司 Data transmission method, electronic device, server and storage medium
CN112184841A (en) * 2020-09-27 2021-01-05 陕西师范大学 Block replacement generating type information hiding and recovering method, device and medium
CN112634119A (en) * 2020-12-24 2021-04-09 深圳壹账通智能科技有限公司 Watermark adding method, watermark adding device, computer equipment and storage medium
CN113240431A (en) * 2021-06-16 2021-08-10 中国银行股份有限公司 Payment verification method and system based on three primary colors of picture pixels
CN113535164A (en) * 2021-06-11 2021-10-22 中电金信软件有限公司 Front-end interface generation method and device, electronic equipment and storage medium

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013258488A (en) * 2012-06-11 2013-12-26 Osaka Gas Co Ltd Encryption key generation system and authentication system
WO2017124940A1 (en) * 2016-01-21 2017-07-27 腾讯科技(深圳)有限公司 Method and device for recognizing whether image comprises watermark
CN107481181A (en) * 2017-07-27 2017-12-15 银江股份有限公司 A kind of picture hidden method, restoring method and picture for being used to protect individual privacy hides system
CN110321673A (en) * 2018-03-28 2019-10-11 北京京东尚科信息技术有限公司 Information ciphering method and device, information decryption method and device, security system
WO2020237868A1 (en) * 2019-05-24 2020-12-03 平安科技(深圳)有限公司 Data transmission method, electronic device, server and storage medium
CN110516462A (en) * 2019-08-30 2019-11-29 京东数字科技控股有限公司 Method and apparatus for encryption data
CN111079189A (en) * 2019-12-30 2020-04-28 联想(北京)有限公司 Information processing method, electronic equipment and computer readable storage medium
CN111898142A (en) * 2020-07-16 2020-11-06 常州工学院 Password hiding and inquiring method based on picture
CN112184841A (en) * 2020-09-27 2021-01-05 陕西师范大学 Block replacement generating type information hiding and recovering method, device and medium
CN112634119A (en) * 2020-12-24 2021-04-09 深圳壹账通智能科技有限公司 Watermark adding method, watermark adding device, computer equipment and storage medium
CN113535164A (en) * 2021-06-11 2021-10-22 中电金信软件有限公司 Front-end interface generation method and device, electronic equipment and storage medium
CN113240431A (en) * 2021-06-16 2021-08-10 中国银行股份有限公司 Payment verification method and system based on three primary colors of picture pixels

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于图像分割和随机LSB的信息隐藏算法;高华玲;;现代计算机(专业版)(第15期);全文 *

Also Published As

Publication number Publication date
CN113810189A (en) 2021-12-17

Similar Documents

Publication Publication Date Title
CN110267115B (en) Video security control method, device, equipment and medium
US10970804B2 (en) Image processing device and image processing method for selecting regions based on gradiation for embedding a watermark
KR20180081470A (en) System for hiding information using lightweight mutual authentication based on biometric in mobile environment, method thereof and computer recordable medium storing program to perform the method
Rejani et al. Pixel pattern based steganography on images
CN113810189B (en) Method and device for generating key picture
CN110189384B (en) Image compression method, device, computer equipment and storage medium based on Unity3D
JP2007206762A (en) Communication method and communication device using two-dimensional code
CN110634096B (en) Self-adaptive multi-mode information hiding method and device
CN109005196A (en) Data transmission method, data decryption method, device and electronic equipment
CN106203141A (en) The data processing method of a kind of application and device
US20220086128A1 (en) System, method and application for transcoding data into media files
Ye et al. PRA-TPE: Perfectly recoverable approximate thumbnail-preserving image encryption
Ye et al. Noise-free thumbnail-preserving image encryption based on MSB prediction
US6023511A (en) Cryptosystem for encrypting digital image or voice file
CN111026583B (en) Backup recovery method for multi-private key of blockchain wallet and computer readable storage medium
US11276138B2 (en) Image data encryption and rendering system
CN115511030A (en) Anti-counterfeiting verification method and device and electronic equipment
CN111092721B (en) Method and device for setting access password
Angel et al. Security Key-Based Steganography for Images
CN115134473B (en) Image encryption method and device
CN111030819A (en) Authentication method, system, terminal and storage medium based on encryption and decryption algorithm
CN110543749A (en) method and device for adding invisible watermark to client
KR102236757B1 (en) Video providing method, server and user terminal device
CN116257868A (en) Data protection method and device based on image steganography, storage medium and terminal
CN111324897B (en) Image encryption method and device and image decryption method and device

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