Data encryption method and device, electronic equipment, storage medium and program product
Through multiple encryption and animation hiding technology, the problem that existing encryption algorithms are easily cracked during storage and transmission is solved, achieving higher data security and reliability.
Patent Information
- Application Number
- CN202411660065.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2024-12-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing encryption algorithms are easily cracked by attackers during storage or transmission, and lack effective data protection measures.
Using multiple encryption methods, the data partition to be encrypted is written to the preset initial image, and the encrypted data image is converted into an animation, so that it is hidden in the animation, and the playback frame rate of the animation is lower or higher than the set value. Increase cracking difficulty.
Through multi-level encryption and animation hiding technology, data security and reliability are improved, and the difficulty of attackers to crack is increased, ensuring the security of data during storage and transmission.
Smart Images

Figure CN119150335A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data security, and in particular to a data encryption method, device, electronic equipment, storage medium and program product. Background Art
[0002] In today's information age, data security has become an increasingly important issue. As a core means of ensuring data security, information encryption technology has developed into multiple levels and types. Among them, application layer transparent encryption and driver layer transparent encryption are two common technologies that can automatically encrypt and decrypt files without the user's awareness, thereby ensuring the security of sensitive information without affecting the user's daily operations.
[0003] The current mainstream encryption algorithms include symmetric encryption algorithms, such as DES (Data Encryption Standard), 3DES (Triple Data Encryption Algorithm), AES (Advanced Encryption Standard), etc., and asymmetric encryption algorithms, such as RSA (Ron Rivest-Adi Shamir-Leonard Adleman), ECC (Elliptic Curve Cryptography), etc. However, in the prior art, data is usually directly stored or transmitted after encryption. Once the storage is attacked or the encrypted data is captured by the attack during the transmission process, the encrypted data can be easily cracked by the attacker. Summary of the invention
[0004] The purpose of the present invention is to provide a data encryption method, device, electronic device, storage medium and program product, which can effectively solve the problems existing in existing encryption algorithms and provide safer and more reliable data protection.
[0005] The embodiments of the present invention can be implemented as follows: In a first aspect, the present invention provides a data encryption method, comprising: Obtain the data to be encrypted; Performing multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and writing the multi-level encrypted data into a preset initial image in partitions to obtain an encrypted data image; Acquire at least one frame of other image, and convert the at least one frame of other image and the encrypted data image into a dynamic image, wherein the encrypted data image is a non-first frame image of the dynamic image and the playback frame rate of the dynamic image is lower than a first set value or higher than a second set value.
[0006] In an optional embodiment, the multi-level encrypted data includes primary encrypted data and secondary encrypted data; the step of performing multiple encryption on the data to be encrypted to obtain the multi-level encrypted data, and writing the multi-level encrypted data partitions into a preset initial image to obtain an encrypted data image includes: Encrypting the data to be encrypted using a first preset encryption algorithm to obtain the first-level encrypted data; Encrypting the primary encrypted data using a second preset encryption algorithm to obtain the secondary encrypted data; Performing UTF-8 encoding on the primary encrypted data and the secondary encrypted data respectively to obtain first encoded data and second encoded data; The first encoded data and the second encoded data are partitioned and written into the preset initial image to obtain the encrypted data image.
[0007] In an optional implementation manner, the step of writing the first coded data and the second coded data into the preset initial image in partitions to obtain the encrypted data image includes: Based on a preset writing rule and the data amounts of the first coded data and the second coded data, respectively, a first writing position and a second writing position of the first coded data and the second coded data are calculated, respectively, within the preset initial image; wherein the first writing position does not overlap with the second writing position; The first coded data and the second coded data are written into the preset initial image according to a first writing position and the second writing position respectively, so as to obtain the encrypted data image.
[0008] In an optional implementation, the pixel value of each pixel in the preset initial image occupies 4 bytes; the step of calculating the first writing position and the second writing position of the first coded data and the second coded data in the preset initial image based on the preset writing rule and the data amounts of the first coded data and the second coded data, respectively, comprises: Calculate the number of first pixels based on the data amount of the first encoded data and the preset single pixel writing bytes; Taking the nth pixel in the first row or the first column of the preset initial image as the first starting pixel; Searching for a first number of pixel points by row or by column from the first starting pixel point, and using each pixel point found as a first pixel point to be written; Taking any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position; Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel writing byte; The nth pixel point which is at least one row or at least one column after the last first pixel point to be written is used as the second starting pixel point; Searching for a second number of pixels by row or by column starting from the second starting pixel point, and using each pixel point found as a second pixel point to be written; Any k bytes of each second pixel to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the writing bytes of the single pixel.
[0009] In an optional implementation, the pixel value of each pixel in the preset initial image occupies 4 bytes; the step of calculating the first writing position and the second writing position of the first coded data and the second coded data in the preset initial image based on the preset writing rule and the data amounts of the first coded data and the second coded data, respectively, comprises: Calculate the number of first pixels based on the data amount of the first encoded data and the preset single pixel writing bytes; From each odd-numbered row of pixels or each odd-numbered column of pixels of the preset initial image, a first number of pixels is selected according to a preset selection rule or randomly, and each selected pixel is used as a first pixel to be written; Taking any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position; Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel writing byte; From each even-numbered row of pixels or each even-numbered column of pixels of the preset initial image, select a second number of pixels according to a preset selection rule or randomly, and use each selected pixel as a second pixel to be written; Any k bytes of each second pixel to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the writing bytes of the single pixel.
[0010] In an optional implementation, the pixel value of each pixel in the preset initial image occupies 4 bytes; the step of calculating the first writing position and the second writing position of the first coded data and the second coded data in the preset initial image based on the preset writing rule and the data amounts of the first coded data and the second coded data, respectively, comprises: Calculate the number of first pixels based on the data amount of the first encoded data and the preset single pixel writing bytes; The first number of pixel points on a diagonal line in the preset initial image are all used as first pixel points to be written; Taking any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position; Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel writing byte; A second number of pixel points on another diagonal line in the preset initial image are all used as second pixel points to be written; Any k bytes of each second pixel to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the writing bytes of the single pixel.
[0011] In a second aspect, the present invention provides a data encryption device, comprising: An acquisition module, used to acquire data to be encrypted; An encryption module is used to: perform multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and write the multi-level encrypted data into a preset initial image to obtain an encrypted data image; A hidden module is used to obtain at least one frame of other images and convert the at least one frame of other images and the encrypted data image into a dynamic image, wherein the encrypted data image is a non-first frame image of the dynamic image and the playback frame rate of the dynamic image is lower than a first set value or higher than a second set value.
[0012] In a third aspect, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the data encryption method as described in the first aspect above.
[0013] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data encryption method described in the first aspect is implemented.
[0014] In a fifth aspect, the present invention provides a program product, which, when executed by a processor, implements the data encryption method described in the first aspect.
[0015] Compared with the prior art, the embodiments of the present invention provide a data encryption method, device, electronic device, storage medium and program product, firstly obtaining the data to be encrypted; then, performing multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and writing the multi-level encrypted data into a preset initial image in partitions to obtain an encrypted data image; then obtaining at least one frame of other images, and converting at least one frame of other images and the encrypted data image into a moving picture. In the present invention, the encrypted data image is a non-first frame image of the moving picture and the playing frame rate of the moving picture is lower than the first set value or higher than the second set value, so that the encrypted data image is hidden in the moving picture and is not easy to be found, and the multi-level encrypted data is written in partitions, which increases the difficulty of cracking and ensures data security. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0017] Figure 1 One of the flow charts of a data encryption method provided in an embodiment of the present invention.
[0018] Figure 2 The second flowchart of a data encryption method provided by an embodiment of the present invention.
[0019] Figure 3 A schematic diagram of storage space occupation of a single pixel in a preset initial image provided by an embodiment of the present invention.
[0020] Figure 4 This is one of the schematic diagrams of the relationship between a first writing position and a second writing position in a preset initial image provided by an embodiment of the present invention.
[0021] Figure 5 The second schematic diagram of the relationship between a first writing position and a second writing position in a preset initial image provided by an embodiment of the present invention.
[0022] Figure 6 The third schematic diagram of the relationship between a first writing position and a second writing position in a preset initial image provided by an embodiment of the present invention.
[0023] Figure 7 A schematic diagram of the structure of a data encryption device provided by an embodiment of the present invention.
[0024] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0026] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0028] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0029] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0030] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0031] The data encryption method provided by the embodiment of the present invention can be applied to electronic devices, which may be smart phones, smart tablets, personal computers, servers, etc.
[0032] Please refer to Figure 1 , Figure 1 A schematic diagram of a data encryption method provided by an embodiment of the present invention includes the following steps S101 to S103: S101: Obtain data to be encrypted.
[0033] In this embodiment, the data to be encrypted may be any form of data that needs to be stored and transmitted confidentially or securely.
[0034] S102, performing multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and writing the multi-level encrypted data partitions into a preset initial image to obtain an encrypted data image.
[0035] In this embodiment, the preset initial image may be a common image selected based on the encryption scenario, or the preset initial image may be a black image with all pixel values of 0 or a white image with all pixel values of 1, which is not limited here.
[0036] S103, obtaining at least one frame of other images, and converting at least one frame of other images and the encrypted data image into a moving image.
[0037] In this embodiment, the encrypted data image is a non-first frame image of the animated image and the playback frame rate of the animated image is lower than the first setting value or higher than the second setting value. The first setting value can be a number infinitely close to 0, so that the animated image can be played at a higher frame rate. Figure 1 The first frame is played straight, so that the encrypted data image is hidden in the moving picture and cannot be seen by the naked eye. The second setting value can be a larger number (for example, setting value ≥ 90 or setting value ≥ 120), so that when the moving picture is played, the playing time of each frame is extremely short, and the naked eye cannot see it, and the hiding effect can also be achieved.
[0038] The data encryption method provided by the embodiment of the present invention first obtains the data to be encrypted; then, the data to be encrypted is multiple-encrypted to obtain multi-level encrypted data, and the multi-level encrypted data is partitioned and written into a preset initial image to obtain an encrypted data image; then at least one frame of other images is obtained, and at least one frame of other images and the encrypted data image are converted into a dynamic image. In the present invention, the encrypted data image is a non-first frame image of the dynamic image and the playback frame rate of the dynamic image is lower than the first set value or higher than the second set value, so that the encrypted data image is hidden in the dynamic image and is not easy to find. In addition, since the multi-level encrypted data is a preset initial image written in a partition, the writing position of the multi-level encrypted data in the preset initial image does not overlap. Even if the attacker finds and extracts the encrypted data image from the dynamic image, it is necessary to cross-verify before taking out the multi-level encrypted data from all pixels of the encrypted data image and then decrypt it, which increases the difficulty of cracking.
[0039] In an optional implementation, the multi-level encrypted data may include primary encrypted data and secondary encrypted data. Figure 1 Based on Figure 2 The sub-steps of the above step S102 may include S1021~S1024.
[0040] S1021. Encrypt the data to be encrypted using a first preset encryption algorithm to obtain first-level encrypted data.
[0041] S1022. Encrypt the primary encrypted data using a second preset encryption algorithm to obtain secondary encrypted data.
[0042] In this embodiment, the first preset encryption algorithm and the second preset encryption algorithm can be flexibly selected based on the actual encryption scenario. For example, when used for software licensing, the first preset encryption algorithm and the second preset encryption algorithm can be AES algorithm and MD5 (Message-Digest Algorithm 5), respectively. This example is only an example and is not limited here.
[0043] S1023. Perform UTF-8 encoding on the first-level encrypted data and the second-level encrypted data respectively to obtain first encoded data and second encoded data.
[0044] In this embodiment, the primary encrypted data and the secondary encrypted data are processed into the first coded data and the second coded data respectively so as to better embed the coded data into the image.
[0045] Optionally, in different application scenarios, the data encrypted using the second preset encryption algorithm may include more than one-level encrypted data, and the first encoded data may also include UTF8-encoded data of the one-level encrypted data.
[0046] For example, in a software licensing scenario, if the data to be encrypted is time information: {"date":"2024-08-08"}, the process of obtaining the first encoded data and the second encoded data is as follows: First determine the current timestamp (assuming it is 1628352000000), and then perform AES encryption on the encrypted data. The encryption password is ai@2024, and the first-level encrypted data obtained is as follows: U2FsdGVKX1 / Gs9zTkSLh8GiB8iByLnrlzrctocMqXTAuU3KpbzkQ+Tya / 4mis8Dn Then some additional information, the current timestamp and the first-level encrypted data are combined to obtain the combined data as follows: {"function":["functionOne","functionTwo"], "license":{"code":"U2FsdGVKX1 / Gs9zTkSLh8GiB8iByLnrlzrctocMqXTAuU3KpbzkQ+Tya / 4mis8Dn"}, "generateDate":16283520000001} The combined data is encoded by UTF8 to obtain first encoded data, the combined data is encrypted by MD5 to obtain secondary encrypted data; and the secondary encrypted data is encoded by UTF8 to obtain second encoded data.
[0047] This example is only an example and is not intended to be limiting.
[0048] S1024. Write the first coded data and the second coded data partitions into a preset initial image to obtain an encrypted data image.
[0049] In this embodiment, the data can be written after the writing positions of the first coded data and the second coded data in the preset initial image are determined based on the preset writing rule and the preset single pixel writing bytes. Wherein, k is an integer belonging to [1, 4], and k represents that there are k bytes in a pixel that need to be written. Therefore, step S1024 may include: S10241, based on a preset writing rule and the data amounts of the first coded data and the second coded data, respectively, calculating a first writing position and a second writing position of the first coded data and the second coded data in a preset initial image; the first writing position and the second writing position do not overlap; S10242. Write the first coded data and the second coded data into a preset initial image according to the first writing position and the second writing position respectively, to obtain an encrypted data image.
[0050] Understandable, see Figure 3 The pixel value of each pixel in the preset initial image occupies 4 bytes, where the pixel value is composed of four channels: red (R channel), green (G channel), blue (B channel) and transparency (A channel), and each of the four channels occupies 1 byte (ie 8 bits).
[0051] On the principle of ensuring that the second writing position and the second writing position do not overlap, the preset writing rule can be flexibly set. Three feasible preset writing rules are introduced below.
[0052] The first preset writing rule: in the preset initial image, write by row / column starting from the set writing starting point, write the first coded data first and then the second coded data, or write the second coded data first and then the first coded data.
[0053] Taking the example of writing the first coded data first and then writing the second coded data, the sub-steps of step S10241 may include S001 to S008: S001. Calculate the number of first pixels based on the amount of first encoded data and a preset single pixel write byte.
[0054] In this embodiment, the ratio of the amount of the first encoded data to the byte k written into a single pixel is calculated (if the ratio is not an integer, it is rounded up), and the first pixel number P can be obtained.
[0055] For example, assuming that the data size of the first encoded data is 3KB, and the single pixel write byte k=3, then the required number of first pixel points P is 1024. This example is only an example and is not limited here.
[0056] S002: Taking the nth pixel point in the first row or the first column of the preset initial image as the first starting pixel point.
[0057] In this embodiment, n represents the position of the pixel point as the writing starting point. Taking writing by row and n=2 as an example, the second pixel point of the first row in the initial image is preset as the first starting pixel point, that is, the writing starting point of the first encoded data. This example is only an example and is not limited here.
[0058] S003 , starting from the first starting pixel point, searching by row or by column to find a first number of pixel points, and using each of the found pixel points as the first pixel point to be written.
[0059] In this embodiment, assuming that the number of the first pixel points is represented by P, P pixel points are found by row or column starting from the first starting pixel point and are all used as the first pixel points to be written.
[0060] S004. Use any k bytes of each first pixel to be written or k bytes at a fixed position as the first writing position.
[0061] In this embodiment, the k bytes to be written in the first pixel to be written may be any k bytes of the 4 bytes, or k bytes at fixed positions of the 4 bytes. For example, the positions to be written in the first pixel to be written may be: the first k bytes, the last k bytes, or k bytes at other fixed positions.
[0062] S005. Calculate the second pixel quantity based on the data volume of the second encoded data and the preset single pixel write bytes.
[0063] In this embodiment, the second pixel quantity Q is obtained by calculating the ratio of the data volume of the second encoded data to the byte k written into a single pixel (if the ratio is not an integer, it is rounded up).
[0064] S006: Take the nth pixel point that is at least one row or at least one column after the last first pixel point to be written as the second starting pixel point.
[0065] After determining the first writing position for writing the first coded data, it is necessary to first determine the writing starting point of the second coded data. In this embodiment, the pixel row / column where the writing starting point of the second coded data is located can be at least one row / column away from the last first pixel to be written.
[0066] S007 , starting from the second starting pixel point, searching by row or by column to find out a second number of pixel points, and using each of the found pixel points as the second pixel point to be written.
[0067] S008. Use any k bytes of each second pixel to be written or k bytes at a fixed position as the second writing position.
[0068] Similarly, the k bytes to be written into the second pixel to be written may be any k bytes among the four bytes, or may be k bytes at fixed positions among the four bytes.
[0069] In the optional example, assuming that writing is done in rows, n=2, k=3, and the k pixels to be written are directly fixed to the first 3 bytes, the pixel row where the writing starting point of the second encoded data is located can be separated by one row from the last pixel to be written, then the first writing position and the second writing position in the preset initial image determined according to the above steps S001 to S008 are as follows: Figure 4 shown.
[0070] Figure 4 In the figure, the preset initial image includes 255*255 pixels, the red area is the first writing position for writing the first encoded data, and the green area is the first writing position for writing the second encoded data, wherein the number of the first pixel points to be written P=508, and the number of the second pixel points to be written Q=256.
[0071] It should be noted that, combined with Figure 4 The examples shown are merely illustrative and are not intended to be limiting.
[0072] The second preset writing rule: in the preset initial image, the first writing position is determined from the even rows / columns, and the second writing position is determined from the odd rows / columns; or the first writing position is determined from the odd rows / columns, and the second writing position is determined from the even rows / columns.
[0073] Taking determining the first writing position from the even rows / columns and determining the second writing position from the odd rows / columns as an example, the sub-steps of step S10241 may include S00A to S008.
[0074] S00A. Calculate the number of first pixel points based on the data amount of the first encoded data and the preset single pixel point writing bytes.
[0075] The method of calculating the first pixel number P in S00A is consistent with the above step S001, which will not be described in detail here.
[0076] S00B. Select a first number of pixels from each odd-numbered row of pixels or each odd-numbered column of pixels of a preset initial image according to a preset selection rule or randomly, and use each selected pixel as a first pixel to be written.
[0077] In this embodiment, the preset selection rule may be: in odd rows / odd columns, even-numbered pixels are randomly selected; and in even rows / even columns, odd-numbered pixels are randomly selected.
[0078] Therefore, P pixels may be randomly selected from pixels in odd rows or pixels in odd columns of a preset initial image as first pixels to be written.
[0079] Alternatively, according to the preset selection rules, P even-numbered pixels can be randomly selected from each odd-numbered row of pixels or each odd-numbered column of pixels in the preset initial image as the first pixel to be written. That is, taking the first row of pixels of the preset initial image as an example, the row includes the 2N pixel points, then a total of N even-numbered pixels (the 2nd, 4th, 6th...2N pixel points) may be selected as the first pixel points to be written, and this example is only an example and is not limited here.
[0080] S00C. Use any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position.
[0081] The method of determining the first writing position in step S00C is consistent with the above step S004, which will not be described in detail here.
[0082] S00D. Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel write bytes.
[0083] The method of calculating the second pixel quantity Q in S00D is consistent with the above step S005, which will not be described in detail here.
[0084] S00E. Select a second number of pixels from each even-numbered row of pixels or each even-numbered column of pixels of the preset initial image according to a preset selection rule or randomly, and use each selected pixel as a second pixel to be written.
[0085] In this embodiment, Q pixels may be randomly selected from pixels in even-numbered rows or even-numbered columns of a preset initial image as first pixels to be written.
[0086] Alternatively, according to the preset selection rules, Q odd-numbered pixels may be randomly selected from each even-numbered row of pixels or each even-numbered column of pixels of the preset initial image as the second pixel to be written. That is, taking the second row of pixels of the preset initial image as an example, the row includes the 2N pixel points, then a total of N odd-numbered pixel points (the 1st, 2nd, 3rd...2N-1 pixel points) may be selected as the second pixel points to be written, and this example is only an example and is not limited here.
[0087] S00F. Use any k bytes or k bytes at a fixed position of each second pixel to be written as the second writing position.
[0088] The method of determining the second writing position in step S00F is consistent with the above step S008, which will not be described in detail here.
[0089] In the optional example, assuming that writing is done in columns and the pixels to be written are selected based on the preset selection rules, k=3 and the k pixels to be written are directly fixed to the first 3 bytes, then the first writing position and the second writing position in the preset initial image determined according to the above steps S00A~S00F are as follows: Figure 5 shown.
[0090] Figure 5 In the figure, the preset initial image includes 8*6 pixels, the red area is the first writing position for writing the first coded data, and the green area is the first writing position for writing the second coded data, wherein the number of the first pixel points to be written P=11, and the number of the second pixel points to be written Q=10. It can be clearly seen that the use of the preset selection rules for selecting the first pixel points to be written and the second pixel points to be written can ensure that the first coded data and the second coded data are written completely staggered, which increases the difficulty of cracking.
[0091] It should be noted that, combined with Figure 5 The examples given are merely illustrative and are not intended to be limiting.
[0092] The third preset writing rule: when the pixel width and pixel height of the preset initial image are equal, the first coded data and the second coded data can be written on two diagonal lines respectively. Therefore, the sub-steps of the above step S10241 may include S00a to S00f.
[0093] S00a. Calculate the number of first pixel points based on the data amount of the first encoded data and the preset single pixel point writing bytes.
[0094] The method of calculating the first pixel number P in S00a is consistent with the above step S001, which will not be described in detail here.
[0095] S00b, taking a first number of pixel points on a diagonal line in a preset initial image as first pixel points to be written.
[0096] In this embodiment, when the pixel width and pixel height of the preset initial image are both odd numbers, the central pixel point of the image is on both a diagonal line (a diagonal line formed by pixel points) and another diagonal line on the preset initial image. Therefore, in order to avoid the first writing position overlapping with the second writing position, in addition to the central pixel point, P pixel points that can be randomly selected on a diagonal line in the preset initial image are all used as the first pixel points to be written.
[0097] When the pixel width and pixel height of the preset initial image are both even numbers, P pixels can be randomly selected directly on a diagonal line in the preset initial image as the first pixels to be written.
[0098] S00c. Use any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position.
[0099] The method of determining the first writing position in step S00c is consistent with the above step S004, which will not be described in detail here.
[0100] S00d. Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel write bytes.
[0101] The method of calculating the second pixel quantity Q in S00d is consistent with the above step S005, which will not be described in detail here.
[0102] S00e, taking a second number of pixel points on another diagonal line in the preset initial image as second pixel points to be written; In this embodiment, when Q pixels are randomly selected on another diagonal line in the preset initial image, the central pixel needs to be excluded to avoid the first writing position from overlapping with the second writing position.
[0103] When the pixel width and pixel height of the preset initial image are both even numbers, Q pixels may be randomly selected on another diagonal line in the preset initial image as the second pixels to be written.
[0104] S00f. Use any k bytes or k bytes at a fixed position of each second pixel to be written as the second writing position.
[0105] The method of determining the second writing position in step S00f is consistent with the above step S008, which will not be described in detail here.
[0106] In an optional example, assuming that the pixel width and pixel height of the preset initial image are both 7, if the first writing position and the second writing position in the preset initial image determined according to the above steps S00a to S00f are as follows: Figure 6 shown.
[0107] Figure 6 In the figure, the yellow area represents the center pixel position, the red area is the first writing position for writing the first encoded data, and the green area is the first writing position for writing the second encoded data, wherein the number of the first pixel points to be written P=4, and the number of the second pixel points to be written Q=5.
[0108] It should be noted that, combined with Figure 6 The examples given are merely illustrative and are not intended to be limiting.
[0109] It is understandable that in practical application, any one of the above three preset writing rules can be flexibly selected based on the data amount of the first coded data and the second coded data. Moreover, the manner of determining the first writing position and the second writing position is not limited to the above three.
[0110] In an optional implementation, in the above step S103, in order to enable the encrypted data image to be hidden in the animated image, the following two methods are adopted: (1) After selecting one image from at least one other image as a first frame image, randomly arrange the other images and the encrypted data image except the first frame image to obtain an image frame sequence; based on a preset playback frame rate (lower than a first set value that is infinitely close to 0), convert the image frame sequence into a moving picture; (2) At least one of the other images is a continuous video frame, and the encrypted data image is inserted between any two other images to obtain an image frame sequence; based on a preset playback frame rate (higher than a larger second set value), the image frame sequence is converted into a moving picture.
[0111] It should be noted that the execution order of each step in the above method embodiment is not limited to that shown in the drawings, and the execution order of each step shall be based on the actual application situation.
[0112] In order to execute the corresponding steps in the above method embodiment and each possible implementation mode, an implementation mode of a data encryption device is given below.
[0113] See also Figure 7 , Figure 7 The data encryption device 200 includes an acquisition module 210 , an encryption module 220 and a hiding module 230 .
[0114] An acquisition module 210 is used to acquire data to be encrypted; The encryption module 220 is used to: perform multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and write the multi-level encrypted data partitions into a preset initial image to obtain an encrypted data image; The hidden module 230 is used to obtain at least one frame of other images and convert at least one frame of other images and the encrypted data image into a dynamic image, wherein the encrypted data image is a non-first frame image of the dynamic image and the playback frame rate of the dynamic image is lower than the first set value or higher than the second set value.
[0115] Optionally, the multi-level encrypted data includes primary encrypted data and secondary encrypted data. The encryption module 220 is used to perform multiple encryption on the encrypted data to obtain the multi-level encrypted data, and write the multi-level encrypted data partitions into a preset initial image. When obtaining the encrypted data image, it can be specifically used to: encrypt the encrypted data using a first preset encryption algorithm to obtain primary encrypted data; encrypt the primary encrypted data using a second preset encryption algorithm to obtain secondary encrypted data; perform UTF-8 encoding on the primary encrypted data and the secondary encrypted data respectively to obtain first encoded data and second encoded data; write the first encoded data and the second encoded data partitions into the preset initial image to obtain the encrypted data image.
[0116] Optionally, the encryption module 220 is used to write the first encoded data and the second encoded data partitions into a preset initial image. When the encrypted data image is obtained, it can be specifically used to: calculate the first write position and the second write position of the first encoded data and the second encoded data in the preset initial image based on a preset write rule and the data amount of each of the first encoded data and the second encoded data; wherein the second write position does not overlap with the second write position; write the first encoded data and the second encoded data into the preset initial image according to the first write position and the second write position, respectively, to obtain the encrypted data image.
[0117] Optionally, the pixel value of each pixel in the preset initial image occupies 4 bytes; the encryption module 220 is used to calculate the first write position and the second write position of the first coded data and the second coded data in the preset initial image based on the preset write rule and the data amount of the first coded data and the second coded data, respectively. Specifically, it can be used to: calculate the number of first pixels based on the data amount of the first coded data and the preset single pixel write bytes; take the nth pixel in the first row or the first column of the preset initial image as the first starting pixel; start from the first starting pixel and search by row or by column to find the first number of pixels, and use each pixel found as the first pixel. A pixel point to be written; any k bytes of each first pixel point to be written or k bytes at a fixed position are used as the first writing position; based on the data amount of the second encoded data and the preset single pixel point writing bytes, the second pixel point quantity is calculated; the nth pixel point separated by at least one row or at least one column after the last first pixel point to be written is used as the second starting pixel point; starting from the second starting pixel point, a second number of pixel points are searched by row or by column, and each pixel point searched is used as the second pixel point to be written; any k bytes of each second pixel point to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the single pixel point writing byte.
[0118] Optionally, the pixel value of each pixel in the preset initial image occupies 4 bytes; the encryption module 220 is used to calculate the first write position and the second write position of the first coded data and the second coded data in the preset initial image based on the preset write rule and the data volume of the first coded data and the second coded data, respectively. Specifically, it can be used to: calculate the number of first pixels based on the data volume of the first coded data and the preset single pixel write bytes; select the first pixel number of pixels from each odd row pixel or each odd column pixel of the preset initial image according to the preset selection rule or randomly, and write each selected pixel point All of them are used as the first pixel points to be written; any k bytes of each first pixel point to be written or k bytes at a fixed position are used as the first writing position; based on the data amount of the second encoded data and the preset single pixel point writing bytes, the second pixel point quantity is calculated; from each even row pixel or each even column pixel of the preset initial image, the second pixel point quantity pixel points are selected according to the preset selection regulations or randomly, and each selected pixel point is used as the second pixel point to be written; any k bytes of each second pixel point to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the single pixel point writing byte.
[0119] Optionally, the pixel value of each pixel in the preset initial image occupies 4 bytes; the encryption module 220 is used to calculate the first writing position and the second writing position of the first coded data and the second coded data in the preset initial image based on the preset writing rule and the data amount of the first coded data and the second coded data, respectively. Specifically, it can be used to: calculate the number of first pixels based on the data amount of the first coded data and the preset single pixel writing byte; use the first number of pixels on a diagonal line in the preset initial image as the first pixels to be written; use any k bytes of each first pixel to be written or k bytes at a fixed position as the first writing position; calculate the number of second pixels based on the data amount of the second coded data and the preset single pixel writing byte; use the second number of pixels on another diagonal line in the preset initial image as the second pixels to be written; use any k bytes of each second pixel to be written or k bytes at a fixed position as the second writing position; wherein k is equal to the single pixel writing byte.
[0120] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the data encryption device 200 described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0121] See also Figure 8 , Figure 8 The electronic device 300 includes a processor 310 , a memory 320 , and a bus 330 , wherein the processor 310 is connected to the memory 320 via the bus 330 .
[0122] The memory 320 may be used to store software programs, for example, software programs corresponding to the data encryption device 200 provided in the embodiment of the present invention. The processor 310 executes various functional applications and data processing to implement the data encryption method provided in the embodiment of the present invention by running the software programs stored in the memory 320.
[0123] Among them, the memory 320 can be but is not limited to: RAM (Random Access Memory), ROM (Read Only Memory), FLASH (Flash Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0124] The processor 310 may be an integrated circuit chip with signal processing capability. The processor 310 may be a general-purpose processor, including: CPU (Central Processing Unit), NP (Network Processor), etc.; it may also be: DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0125] Understandably, Figure 8 The structure shown is for illustration only. The electronic device 300 may also include Figure 8 More or fewer components as shown, or with Figure 8 Different configurations are shown. Figure 8 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0126] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the data encryption method disclosed in the above embodiment is implemented. The computer-readable storage medium can be, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a FLASH disk, or an optical disk.
[0127] The embodiment of the present invention further provides a program product, which implements the data encryption method disclosed in the above embodiment when executed by a processor.
[0128] In summary, the embodiments of the present invention provide a data encryption method, device, electronic device, storage medium and program product, firstly obtaining the data to be encrypted; then, performing multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and writing the multi-level encrypted data into a preset initial image in partitions to obtain an encrypted data image; then obtaining at least one frame of other images, and converting at least one frame of other images and the encrypted data image into a moving picture. In the present invention, the encrypted data image is a non-first frame image of the moving picture and the playing frame rate of the moving picture is lower than the first set value or higher than the second set value, so that the encrypted data image is hidden in the moving picture and is not easy to find, and the multi-level encrypted data is written in partitions, which increases the difficulty of cracking and ensures data security.
[0129] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A data encryption method, characterized in that: include: Obtain the data to be encrypted; Performing multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and writing the multi-level encrypted data into a preset initial image in partitions to obtain an encrypted data image; Acquire at least one frame of other image, and convert the at least one frame of other image and the encrypted data image into a dynamic image, wherein the encrypted data image is a non-first frame image of the dynamic image and the playback frame rate of the dynamic image is lower than a first set value or higher than a second set value.
2. The method according to claim 1, characterized in that The multi-level encrypted data includes primary encrypted data and secondary encrypted data; the step of performing multiple encryption on the data to be encrypted to obtain the multi-level encrypted data, and writing the multi-level encrypted data partitions into a preset initial image to obtain an encrypted data image comprises: Encrypting the data to be encrypted using a first preset encryption algorithm to obtain the first-level encrypted data; Encrypting the primary encrypted data using a second preset encryption algorithm to obtain the secondary encrypted data; Performing UTF-8 encoding on the primary encrypted data and the secondary encrypted data respectively to obtain first encoded data and second encoded data; The first encoded data and the second encoded data are partitioned and written into the preset initial image to obtain the encrypted data image.
3. The method according to claim 2, characterized in that The step of writing the first coded data and the second coded data into the preset initial image in partitions to obtain the encrypted data image comprises: Based on a preset writing rule and the data amounts of the first coded data and the second coded data, respectively, a first writing position and a second writing position of the first coded data and the second coded data are calculated, respectively, within the preset initial image; wherein the first writing position does not overlap with the second writing position; The first coded data and the second coded data are written into the preset initial image according to a first writing position and the second writing position respectively, so as to obtain the encrypted data image.
4. The method according to claim 3, characterized in that The pixel value of each pixel in the preset initial image occupies 4 bytes; the step of calculating the first writing position and the second writing position of the first coded data and the second coded data in the preset initial image based on the preset writing rule and the data amount of the first coded data and the second coded data, respectively, comprises: Calculate the number of first pixels based on the data amount of the first encoded data and the preset single pixel writing bytes; Taking the nth pixel in the first row or the first column of the preset initial image as the first starting pixel; Searching for a first number of pixel points by row or by column from the first starting pixel point, and using each pixel point found as a first pixel point to be written; Taking any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position; Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel writing byte; The nth pixel point which is at least one row or at least one column after the last first pixel point to be written is used as the second starting pixel point; Searching for a second number of pixels by row or by column starting from the second starting pixel point, and using each pixel point found as a second pixel point to be written; Any k bytes of each second pixel to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the writing bytes of the single pixel.
5. The method according to claim 3, characterized in that: The pixel value of each pixel in the preset initial image occupies 4 bytes; the step of calculating the first writing position and the second writing position of the first coded data and the second coded data in the preset initial image based on the preset writing rule and the data amount of the first coded data and the second coded data, respectively, comprises: Calculate the number of first pixels based on the data amount of the first encoded data and the preset single pixel writing bytes; From each odd-numbered row of pixels or each odd-numbered column of pixels of the preset initial image, a first number of pixels is selected according to a preset selection rule or randomly, and each selected pixel is used as a first pixel to be written; Taking any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position; Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel writing byte; From each even-numbered row of pixels or each even-numbered column of pixels of the preset initial image, select a second number of pixels according to a preset selection rule or randomly, and use each selected pixel as a second pixel to be written; Any k bytes of each second pixel to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the writing bytes of the single pixel.
6. The method according to claim 3, characterized in that: The pixel value of each pixel in the preset initial image occupies 4 bytes; the step of calculating the first writing position and the second writing position of the first coded data and the second coded data in the preset initial image based on the preset writing rule and the data amount of the first coded data and the second coded data, respectively, comprises: Calculate the number of first pixels based on the data amount of the first encoded data and the preset single pixel writing bytes; The first number of pixel points on a diagonal line in the preset initial image are all used as first pixel points to be written; Taking any k bytes or k bytes at a fixed position of each first pixel to be written as the first writing position; Calculate the second pixel quantity based on the data amount of the second encoded data and the preset single pixel writing byte; A second number of pixel points on another diagonal line in the preset initial image are all used as second pixel points to be written; Any k bytes of each second pixel to be written or k bytes at a fixed position are used as the second writing position; wherein k is equal to the writing bytes of the single pixel.
7. A data encryption device, characterized in that: include: An acquisition module, used to acquire data to be encrypted; An encryption module is used to: perform multiple encryption on the data to be encrypted to obtain multi-level encrypted data, and write the multi-level encrypted data into a preset initial image to obtain an encrypted data image; A hidden module is used to obtain at least one frame of other images and convert the at least one frame of other images and the encrypted data image into a dynamic image, wherein the encrypted data image is a non-first frame image of the dynamic image and the playback frame rate of the dynamic image is lower than a first set value or higher than a second set value.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the data encryption method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data encryption method according to any one of claims 1 to 6 is implemented.
10. A program product, which implements the data encryption method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
Data encryption method and system for physical management platform, terminal and storage medium
CN111859424A
City three-dimensional map video stream encryption method and system based on artificial intelligence
CN113963095A
Image encryption and decryption method, electronic equipment, storage medium and program product
CN115250314A
Data protection method and device based on image steganography, storage medium and terminal
CN116257868A
Image encryption method and device, electronic equipment and storage medium
CN117113368A
