Data encryption method, decryption method, device, electronic device and storage medium
By randomly selecting and confusing data in data encryption, and generating keys, the contradiction between security and efficiency of traditional algorithms is solved, and efficient encryption and security of large data files are achieved, especially the encryption of video files. , enhanced resistance to quantum computing cracking.
Patent Information
- Application Number
- CN202111255183.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-10-27
AI Technical Summary
There is a contradiction between security and efficiency in traditional data encryption algorithms. Especially for large data files such as video files, security is difficult to guarantee and can be easily cracked by quantum computing.
By randomly selecting data from the target object, generating random sequences for obfuscation operations, and generating keys based on bit changes, data encryption and decryption can be achieved, reducing the amount of encryption and improving security.
While ensuring data security, it improves encryption efficiency, avoids the dependence on traditional encryption algorithm keys, expands the key space, and enhances security.
Smart Images

Figure CN113987535B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data security technology, and in particular to a data encryption method, a decryption method, a device, an electronic device and a storage medium. Background Art
[0002] Encrypting and decrypting data is an important means to maintain data security.
[0003] In the traditional data security field, the security and efficiency of encryption and decryption are contradictory. If a complex encryption and decryption algorithm is used, the security of encryption and decryption will be improved, but it will also bring huge computing overhead and reduce the efficiency of encryption and decryption. On the contrary, if a relatively simple encryption and decryption algorithm is used, it can certainly reduce computing overhead and improve the efficiency of encryption and decryption, but it is also easy to be cracked, thus bringing security risks.
[0004] Especially for files with large amounts of data, such as video files, the contradiction between encryption and decryption security and encryption and decryption efficiency is particularly prominent.
[0005] In addition, existing traditional encryption algorithms, such as AES, RSA, and ECC, are relatively safe based on the current computer architecture. However, the security of these algorithms increases with the complexity of the algorithms, and they require a lot of computing overhead for encryption objects with large amounts of data, such as videos. In addition, with the development of quantum computing, these algorithms based on the current cryptographic system will face a great risk of being cracked. Summary of the invention
[0006] In view of the problems existing in the prior art, the present invention provides a data encryption method, a decryption method, a device, an electronic device and a storage medium.
[0007] The present invention provides a data encryption method, comprising:
[0008] Selecting data from a target object to obtain a first data set and location information of each data in the first data set in the target object;
[0009] Generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object;
[0010] Performing an obfuscation operation on each data in the second data set to obtain a third data set, and obtaining position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object;
[0011] Writing each data in the third data set back to the target object according to the location information of each data in the third data set in the target object to obtain an encrypted target object;
[0012] A key for the encrypted target object is generated according to a comparison result between the target object and the encrypted target object.
[0013] According to a data encryption method provided by the present invention, generating a random sequence, selecting data from the first data set according to the random sequence, and obtaining a second data set includes:
[0014] Generate a first random sequence according to a preset selection key, wherein the random numbers in the first random sequence present a power-law distribution within the interval [1, L]; wherein L is the data length of the data included in the first data set;
[0015] According to the values of each random number in the first random sequence, data is selected from the first data set to obtain a second data set.
[0016] According to a data encryption method provided by the present invention, generating a first random sequence according to a preset selection key includes:
[0017] According to the preset selection key, a pseudo-random number R in the interval (0, 1) is generated based on a pseudo-random sequence generator. pse ;
[0018] According to the data length L of the data contained in the first data set, calculate A plurality of random numbers showing a power-law distribution in the interval [1, L] are obtained, and the plurality of random numbers constitute a first random sequence; wherein ceil represents a rounding-up operation.
[0019] According to a data encryption method provided by the present invention, the pseudo-random number R in the interval (0, 1) is generated. pse include:
[0020] According to the importance of the data in the first data set, the generated pseudo-random number R in the interval (0, 1) is determined. pse The more important the data is, the more pseudo-random numbers R pse The greater the number.
[0021] According to a data encryption method provided by the present invention, generating a random sequence, selecting data from the first data set according to the random sequence, and obtaining a second data set includes:
[0022] Dividing the data in the first data set into a plurality of groups according to the order of positions;
[0023] According to the importance of the data in the group, a plurality of evenly distributed pseudo-random sequences are allocated to each of the plurality of groups; wherein the higher the importance of the data in the group, the smaller the number of the evenly distributed pseudo-random sequences corresponding to the group;
[0024] Performing a bitwise AND operation on a plurality of uniformly distributed pseudo-random sequences corresponding to each group, to obtain a second random sequence corresponding to each group;
[0025] Data is selected from each group according to the value of each random number in the second random sequence corresponding to each group, and the set of selected data is the second data set.
[0026] According to a data encryption method provided by the present invention, performing an obfuscation operation on each data in the second data set to obtain a third data set includes:
[0027] Generate a third random sequence based on a pseudo-random sequence generator, wherein the data length of the third random sequence is equal to the data length of the data included in the second data set;
[0028] The data in the second data set is replaced with a third random sequence to obtain a third data set.
[0029] According to a data encryption method provided by the present invention, generating a key of the encrypted target object according to a comparison result between the target object and the encrypted target object includes:
[0030] Compare the encrypted target object with the target object bit by bit, record the changed bits as the first value, and record the unchanged bits as the second value, to obtain a binary sequence for recording the bit change; wherein the first value is one of the binary values, and the second value is another value in the binary value that is different from the first value;
[0031] Performing binary run-length coding on the binary sequence to obtain a coded sequence;
[0032] The encoding sequence is entropy encoded to obtain the encrypted key of the target object.
[0033] According to a data encryption method provided by the present invention, the step of selecting data from a target object to obtain a first data set and location information of each data in the first data set in the target object includes:
[0034] When the target object is an independent coding unit in a video bitstream, selecting the leading bytes of a specified length and coefficient residual information of a luminance block in an intra-frame prediction block from the independent coding unit to obtain a first data set;
[0035] According to the selected bytes and the position of the coefficient residual information of the luminance block in the intra-frame prediction block in the independent coding unit, the position information of each data in the first data set in the target object is obtained.
[0036] According to a data encryption method provided by the present invention, the step of selecting data from a target object to obtain a first data set and location information of each data in the first data set in the target object includes:
[0037] In the case where the target object is an independent coding unit in a video code stream, all data are selected from the independent coding unit to obtain a first data set and position information of each data in the first data set in the target object.
[0038] The present invention also provides a data decryption method, comprising:
[0039] Acquire the encrypted target object and the key of the encrypted target object obtained based on the data encryption method;
[0040] According to the key of the encrypted target object, obtaining a position where the encrypted target object has a value change compared to the target object;
[0041] According to the position where the value change occurs in the encrypted target object, the corresponding bit position in the encrypted target object is flipped to obtain the target object.
[0042] According to a data decryption method provided by the present invention, obtaining the position where the encrypted target object changes in value compared with the target object according to the key of the encrypted target object comprises:
[0043] Performing entropy decoding on the encrypted key of the target object to obtain a coding sequence;
[0044] The coding sequence is decoded by binary run-length coding to obtain a binary sequence; wherein the first value in the binary sequence indicates that the value of the corresponding position in the encrypted target object has changed compared with the value in the target object; and the second value in the binary sequence indicates that the value of the corresponding position in the encrypted target object has not changed compared with the value in the target object.
[0045] The present invention also provides a data encryption device, comprising:
[0046] A first data selection module, used to select data from a target object, and obtain a first data set and location information of each data in the first data set in the target object;
[0047] a second data selection module, configured to generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object;
[0048] an obfuscation module, configured to perform an obfuscation operation on each data in the second data set to obtain a third data set, and obtain position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object;
[0049] A write-back module, used for writing each data in the third data set back to the target object according to the position information of each data in the third data set in the target object, so as to obtain an encrypted target object;
[0050] The key generation module is used to generate a key of the encrypted target object according to a comparison result between the target object and the encrypted target object.
[0051] The present invention also provides a data decryption device, comprising:
[0052] A receiving module, used for receiving the encrypted target object and the key of the encrypted target object obtained based on the data encryption device;
[0053] A position information acquisition module, used for obtaining a position where the encrypted target object has a value change compared to the target object according to the key of the encrypted target object;
[0054] The flip module is used to flip the corresponding bits in the encrypted target object according to the position where the value change occurs in the encrypted target object to obtain the target object.
[0055] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the data encryption method or the steps of the data decryption method are implemented.
[0056] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the data encryption method or the steps of the data decryption method are implemented.
[0057] The data encryption method, decryption method, device, electronic device and storage medium provided by the present invention can reduce the amount of data encryption while ensuring the security of the data by randomly selecting data from the target object, performing an obfuscation operation on the selected data, and finally writing the obfuscated data back to the target object, thereby achieving a good balance between security and efficiency. In addition, the security of the data encryption method, decryption method, device, electronic device and storage medium of the present invention does not rely on the key of the traditional encryption algorithm, has a larger key space, and has a higher level of security. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 It is a flow chart of the data encryption method provided by the present invention;
[0060] Figure 2 It is a flow chart of the data decryption method provided by the present invention;
[0061] Figure 3 is a schematic flow chart of a first selection process implemented in an embodiment of the present invention;
[0062] Figure 4 It is a schematic diagram of data selection based on a random sequence in the data encryption method provided by the present invention;
[0063] Figure 5 is a schematic diagram of a data encryption device provided by the present invention;
[0064] Figure 6 is a schematic diagram of a data decryption device provided by the present invention;
[0065] Figure 7 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. 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.
[0067] Combine the following Figure 1-Figure 7 The present invention describes a data encryption method, a decryption method, a device, an electronic device and a storage medium.
[0068] Figure 1 The flowchart of the data encryption method provided by the present invention is as follows: Figure 1 As shown, the data encryption method provided by the present invention includes:
[0069] Step 101: Select data from a target object to obtain a first data set and location information of each data in the first data set in the target object.
[0070] In this embodiment, the target object is an object to be encrypted. The target object can be a text file, an audio file, a video file, etc., or a part of a text file, an audio file or a video file. In this embodiment, each independent coding unit of the video coding layer obtained by decomposing the encoded video file can be used as the target object.
[0071] If the target object contains a large amount of data, such as an uncompressed video file, the process of encrypting the target object will take up a large amount of storage space and computing resources. Therefore, in this embodiment, it is necessary to select data from the target object, and the set of the selected data is recorded as the first data set. It should be noted that, since data is stored and processed in the form of binary numbers in a computer, the data referred to in this application are all represented in binary form.
[0072] The selected data have respective positions in the target object, so after the selected data is determined, the position information of the selected data in the target object can be obtained.
[0073] For example, assuming that the target object is a binary two-byte string of "1100011011010110", if the selected data is the last four bits of the two bytes in the string, then the obtained first data set is "01100110", and the position information of the data in the first data set in the target object is "5, 6, 7, 8, 13, 14, 15, 16".
[0074] There are many implementations for selecting data from a target object. In the following embodiments, how to select data from a target object will be further described.
[0075] Step 102: Generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain the position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object.
[0076] A random sequence, also known as a random number sequence, is a sequence of numbers composed of random variables.
[0077] The values of random variables in a random sequence are randomly determined, so data can be selected from the first data set in a random manner according to the random sequence. For example, in one example, the value range of the random variables in the random sequence is 0 or 1, that is, the random sequence is a binary value sequence. The values of random variables at different positions in the random sequence are random, and the length of the random sequence (that is, the number of random variables contained) is the same as the data length of the first data set. Therefore, the random variables in the random sequence are matched with the data in the first data set according to the positional relationship, and then the data in the first set corresponding to the random variables with a value of 1 is used as the data selected this time. If the aforementioned first data set is "01100110", assuming that the generated random sequence is "01001100", then the data selected from the first data set is "101", that is, the second data set is "101". Combining the position information “5, 6, 7, 8, 13, 14, 15, 16” of the data in the first data set in the target object, it can be known that the position information of the data in the second data set in the target object is “6, 13, 14”.
[0078] The form of the random sequence is not limited to the above-mentioned binary value sequence, but can also be a sequence composed of some random numbers in the form of integers. The value range of these random numbers is between 0-L, where L represents the data length of the first data set. Data can be selected from the first data set based on these random numbers. For example, in one example, the first data set contains 50 data. If the generated random numbers are 1, 3, 8, 15, and 38, then the 1st, 3rd, 8th, 15th, and 38th data are selected from the first data set to generate the second data set.
[0079] Step 103: perform an obfuscation operation on each data in the second data set to obtain a third data set, and obtain the position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object.
[0080] Through the previous operation, a part of the data can be selected from the target object, thereby achieving the purpose of reducing the amount of data processing. In this step, in order to enhance data security, it is necessary to perform an obfuscation operation on the selected data.
[0081] The obfuscation operation may be in various forms, such as encryption operation, replacement operation, etc. In this embodiment, the form of the obfuscation operation is not limited.
[0082] After the obfuscation operation, the data in the second data set may change its value, thereby obtaining a third data set. For example, after the encryption operation, the data in the second data set "101" is converted into the third data set "110".
[0083] It should be noted that, for a single data in the second data set, its value may change or remain unchanged after the obfuscation operation. For example, the value of a certain data after encryption calculation is exactly the same as the value before encryption calculation. However, for the second data set as a whole, the data inside it should change after the obfuscation operation, so as to achieve the purpose of enhancing security.
[0084] In the obfuscation operation, only the value of the data is changed, and the location information of the data does not change. Therefore, the location information of each data in the second data set in the target object can be used to obtain the location information of each data in the third data set in the target object. For example, if the location information of the data in the second data set is "6, 13, 14", the location information of the data in the third data set is also "6, 13, 14".
[0085] Step 104: write each data in the third data set back to the target object according to the location information of each data in the third data set in the target object to obtain an encrypted target object.
[0086] Through the previous steps, some data is selected from the target object, and the selected data is processed to enhance security. In this step, these data can be written back to the target object, thereby obtaining an encrypted target object.
[0087] Since the location information of each data in the third data set in the target object is known, the data in the third data set can be directly written back to the target object according to the location information.
[0088] For example, the target object is a string of "1100011011010110", the third data set is "110", the location information of the data in the third data set is "6, 13, 14", the data in the third data set is written back to the target object, and the encrypted target object is "1100011011011010".
[0089] Step 105: Generate a key for the encrypted target object according to a comparison result between the target object and the encrypted target object.
[0090] The key is the key to data decryption. In this step, the corresponding key needs to be generated while encrypting the target object.
[0091] In this embodiment, the key is generated based on the location information of the data whose value has changed in the target object, that is, the key records the location of the data whose value has changed between the encrypted target object and the original target object.
[0092] For example, the target object in the preceding example is the binary string "1100011011010110", and the encrypted target object is the binary string "1100011011011010". By comparing the two data bits one by one, it can be known that the data whose values have changed are located at positions "13, 14", so the key can be generated from this position information.
[0093] In order to improve transmission efficiency, when generating a key from the aforementioned position information, the position information may be encoded. For example, after encoding the aforementioned position information "13, 14", the key represented by a binary sequence is "1011100110011".
[0094] It should be noted that, in this embodiment, the target object can be a part of a file to be encrypted, such as an independent coding unit in a video file. Therefore, if the entire file to be encrypted needs to be encrypted, the file to be encrypted can be divided into multiple parts, and then these parts are encrypted according to the aforementioned steps, and finally the encrypted results are spliced to obtain the encryption result of the entire file to be encrypted. Similarly, corresponding position information can be generated for each part of the file to be encrypted, and then these position information can be spliced together, and then the encoding operation can be performed to obtain the key of the entire file to be encrypted.
[0095] The data encryption method provided by the present invention randomly selects data from the target object, performs an obfuscation operation on the selected data, and finally writes the obfuscated data back to the target object, thereby reducing the amount of data encryption while ensuring the security of the data, and achieving a good balance between security and efficiency. In addition, the security of the data encryption method of the present invention does not rely on the key of the traditional encryption algorithm, the key space is larger, and it has a higher level of security.
[0096] Based on any of the above embodiments, in this embodiment, generating a random sequence and selecting data from the first data set according to the random sequence to obtain a second data set includes:
[0097] Generate a first random sequence according to a preset selection key, wherein the random numbers in the first random sequence present a power-law distribution within the interval [1, L]; wherein L is the data length of the data included in the first data set;
[0098] According to the values of each random number in the first random sequence, data is selected from the first data set to obtain a second data set.
[0099] In this embodiment, a method for generating a random sequence is further described.
[0100] Specifically, when generating the first random sequence, a pseudo-random sequence generator (PRNG) generated by any algorithm can be used to generate multiple pseudo-random numbers R uniformly distributed in the interval (0, 1). pse ; Then, according to the data length L of the data contained in the first data set, calculate A plurality of random numbers showing a power-law distribution in the interval [1, L] are obtained, and the plurality of random numbers form a first random sequence. Wherein, ceil represents a rounding-up operation.
[0101] For example, if the target object is a string of "1100011011010110", and all the data is selected, the first data set is "1100011011010110". The data length L = 16, and five pseudo-random numbers R are generated by PRNG. pse1= 0.17, R pse2= 0.38, R pse3= 0.53, R pse4= 0.77, R pse5= 0.95. Through the function F(L), five power-law distributed random numbers 2, 3, 5, 9, 14 can be obtained. The 2nd, 3rd, 5th, 9th and 14th data are selected from the first data set to obtain the second data set "10011". The position information of the data in the second data set is "2, 3, 5, 9, 14".
[0102] The operation of selecting data through a power-law distributed random sequence can be applied to application scenarios with strong correlation between the front and back data. For example, for a video bitstream, in each independent coding area, since the encoding process highly compresses the video data, the data dependency in the compressed bitstream is enhanced, and each bit change will have a great impact on the subsequent bitstream decoding. Therefore, the first byte of each independent coding unit is more important. If these data are selected for encryption, the scope of influence can be expanded and the degree of visual degradation of the encrypted video can be enhanced. The power-law distributed random sequence can select more front-end data and further reduce the amount of encrypted data.
[0103] It should be noted that multiple pseudo-random numbers R uniformly distributed in the interval (0, 1) are generated. pse When the plurality of pseudo-random numbers R are determined according to the importance of the data in the first data set, pse The more important the data is, the more pseudo-random numbers R are generated. pse The more the number of pseudo-random numbers R pse The more the number of The more random numbers in the calculated [1, L] interval that present a power-law distribution, the more random numbers in the first random sequence can be increased. Furthermore, more data can be selected from the first data set, which means that more content of the target object can be retained.
[0104] The data encryption method provided by the present invention can select more front-end data in application scenarios with strong correlation between front and back data by selecting a random sequence with power-law distribution, thereby reducing the amount of encrypted data.
[0105] Based on any of the above embodiments, in this embodiment, generating a random sequence and selecting data from the first data set according to the random sequence to obtain a second data set includes:
[0106] Generate a first random sequence according to a preset selection key, wherein the random numbers in the first random sequence present an exponential distribution within the interval [1, L]; wherein L is the data length of the data included in the first data set;
[0107] According to the values of each random number in the first random sequence, data is selected from the first data set to obtain a second data set.
[0108] In the previous embodiment, a process of generating multiple random numbers that present a power-law distribution in the interval [1, L] and generating a first random sequence based on these random numbers is described. The random numbers used to form the first random sequence can not only present a power-law distribution in the interval [1, L], but also present an exponential distribution in the interval [1, L].
[0109] Specifically, when generating the first random sequence, a pseudo-random sequence generator (PRNG) generated by any algorithm can be used to generate multiple pseudo-random numbers R uniformly distributed in the interval (0, 1). pse ; Then, according to the data length L of the data contained in the first data set, calculate G(L)=ceil(-log2(1-(1-2 -L )R pse )) to obtain a plurality of random numbers in the range [1, L] that present an exponential distribution, wherein the plurality of random numbers constitute a first random sequence. Wherein, ceil represents an upward rounding operation.
[0110] For example, if the target object is a string of "1100011011010110", and all the data is selected, the first data set is "1100011011010110". The data length L = 16, and five pseudo-random numbers R are generated by PRNG. pse1= 0.17, R pse2= 0.38, R pse3= 0.53, R pse4= 0.77, R pse5= 0.95. Through the function G(L), five exponentially distributed random numbers 1, 1, 2, 3, 5 can be obtained. The first, second, third and fifth data are selected from the first data set to obtain the second data set "1100". The position information of the data in the second data set is "1, 2, 3, 5".
[0111] Exponentially distributed random sequences can also be applied to application scenarios where data has strong correlation before and after. The data encryption method provided by the present invention can select more front-end data in application scenarios where data has strong correlation before and after by selecting an exponentially distributed random sequence, thereby reducing the amount of encrypted data.
[0112] Based on any of the above embodiments, in this embodiment, generating a random sequence and selecting data from the first data set according to the random sequence to obtain a second data set includes:
[0113] Dividing the data in the first data set into a plurality of groups according to the order of positions;
[0114] According to the importance of the data in the group, a plurality of evenly distributed pseudo-random sequences are allocated to each of the plurality of groups; wherein the higher the importance of the data in the group, the smaller the number of the evenly distributed pseudo-random sequences corresponding to the group;
[0115] Performing a bitwise AND operation on a plurality of uniformly distributed pseudo-random sequences corresponding to each group, to obtain a second random sequence corresponding to each group;
[0116] Data is selected from each group according to the value of each random number in the second random sequence corresponding to each group, and the set of selected data is the second data set.
[0117] In this embodiment, a process of generating a random sequence using a pseudo-random sequence and then performing data selection is described.
[0118] A pseudo-random sequence is a definite sequence with certain random characteristics. If the target object is obtained from a large data volume file such as a video file, the length of the pseudo-random sequence is generally much smaller than the length of the first data set, and the cost of generating the pseudo-random sequence is also much smaller than data encryption. Therefore, the use of pseudo-random sequences can greatly improve encryption efficiency and ensure algorithm security.
[0119] In this embodiment, a plurality of uniformly distributed pseudo-random sequences may be used to generate a corresponding random sequence. Specifically, a plurality of independent selection keys may be used to generate a plurality of pseudo-random sequences through an arbitrary pseudo-random sequence generator; and then these pseudo-random sequences are bitwise ANDed to obtain a random sequence.
[0120] For example, there are three pseudo-random sequences, namely "1010001001", "0110101010", and "0010011001". By performing a bitwise AND operation on these pseudo-random sequences, we get the random sequence "0010001000".
[0121] According to the characteristics of the AND operation, the result of the AND operation is 1 only when both operands of the AND operation are 1; and when selecting data according to the random sequence, the data in the first data set corresponding to the bit with a value of "1" in the random sequence is generally selected. Therefore, as the number of pseudo-random sequences increases, the amount of data that can be selected from the first data set will decrease exponentially. For example, there are 4 pseudo-random sequences, namely "1010001001", "0110101010", "0010011001", and "1100011001". These pseudo-random sequences are subjected to bitwise AND operation to obtain the random sequence "0000001000". Compared with the case where there are 3 pseudo-random sequences mentioned above, the number of bits with a value of "1" in the random sequence is further reduced.
[0122] Based on the above characteristics, in this embodiment, the number of pseudo-random sequences can be determined according to the importance of the data, and then the amount of selected data can be determined.
[0123] For example, the first data set is obtained from an independent coding unit in a video compression code stream, and the first data set can be divided into multiple groups according to the positional relationship of the data in the first data set in the independent coding unit. Since the data in the compressed code stream is highly dependent, the importance of the front bytes in each independent coding unit is higher than that of the back bytes. Therefore, a smaller pseudo-random sequence can be assigned to the front group in the first data set, and a larger pseudo-random sequence can be assigned to the back group. Each group performs a bitwise AND operation on the pseudo-random sequence assigned to the group to obtain the second random sequence corresponding to each group. Each group selects data according to the second random sequence corresponding to the group, and the data selected by all groups are summarized to obtain the second data set.
[0124] The data encryption method provided by the present invention determines the amount of selected data according to the importance of the data, and while reducing the amount of encrypted data and improving encryption efficiency, it also ensures the security of important data.
[0125] Based on any of the above embodiments, in this embodiment, performing an obfuscation operation on each data in the second data set to obtain a third data set includes:
[0126] Generate a third random sequence based on a random number generator, wherein the data length of the third random sequence is equal to the data length of the data included in the second data set;
[0127] The data in the second data set is replaced with a third random sequence to obtain a third data set.
[0128] The obfuscation operation can be implemented in many ways, such as encryption operation, replacement operation, etc. In this embodiment, one implementation of the obfuscation operation is described.
[0129] Specifically, the third random sequence can be generated by any random number generator, and the data length of the third random sequence is equal to the data length of the data included in the second data set. Then the third random sequence is used to replace the data in the second data set to obtain the third data set.
[0130] For example, in one example, the second data set is "11010100", and its data length is 9, so a random sequence of length 9 is generated by a random number generator, such as "001001111". This random sequence replaces the data in the second data set to obtain the third data set "001001111".
[0131] When encrypting the target object, the key lies in which data is selected from the target object for the obfuscation operation (i.e., the location information of the selected data), and it does not matter how the value of the selected data changes. Therefore, even if the data in the second data set is replaced with a random number that is completely unrelated to the original data, it does not affect the subsequent key generation operation or decryption operation. Replacing the data in the second data set with a random number that is completely unrelated to the original data actually increases the difficulty of cracking and improves the security of the data.
[0132] The data encryption method provided by the present invention increases the difficulty of cracking and improves the security of data by replacing the data selected from the target object with random numbers.
[0133] Based on any of the above embodiments, in this embodiment, generating a key of the encrypted target object according to a comparison result between the target object and the encrypted target object includes:
[0134] Compare the encrypted target object with the target object bit by bit, record the changed bits as the first value, and record the unchanged bits as the second value, to obtain a binary sequence for recording the bit change; wherein the first value is one of the binary values, and the second value is another value in the binary value that is different from the first value;
[0135] Performing binary run-length coding on the binary sequence to obtain a coded sequence;
[0136] The encoding sequence is entropy encoded to obtain the encrypted key of the target object.
[0137] In the previous embodiment, the process of how to encrypt the target object has been described. In this embodiment, the process of generating the key is described.
[0138] The key records the location of the data whose value has changed between the encrypted target object and the original target object. When generating the key, the encrypted target object can be compared bit by bit with the target object first, and the comparison results are divided into two categories. One is the change, and the changed bit can be recorded as the first value, such as the binary value "1"; the other is the unchanged bit, and the unchanged bit can be recorded as the second value, such as the binary value "0". The result of the bit-by-bit comparison between the encrypted target object and the target object can form a binary sequence.
[0139] Next, after obtaining the binary sequence, in order to improve the key transmission efficiency, it is also necessary to perform binary run-length encoding on the binary sequence.
[0140] Since the first bit of the target object is usually fixed-format data, such as the NAL unit header data in the video, it is not meaningful to encrypt the data, and it is generally not selected, and its value generally does not change. Therefore, the first bit in the binary sequence obtained by comparing the encrypted target object with the target object bit by bit is generally 0.
[0141] Finally, the result of binary run-length coding is entropy coded to obtain the encrypted key of the target object.
[0142] There are many ways of entropy coding, such as Huffman coding, arithmetic coding, etc. In this embodiment, Huffman coding is used. For example, the result of binary run-length coding is regarded as consisting of 11 states of "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" and "", and the data is Huffman encoded according to the frequency of occurrence to form the key of the encrypted target object.
[0143] For example, the target object in the above example is the binary string "1100011011010110", and the encrypted target object is the binary string "1100011011011010". By comparing the two data bits one by one, we can know that the data with changed values are located at the two positions "13, 14", so the key "0000000000001100" can be generated from this position information. In view of the fact that the binary sequence is a binary code, and the value of the first bit in the binary sequence is generally fixed (usually 0), when performing binary run-length coding on the binary sequence, it is only necessary to record the number of consecutive occurrences of 0 or 1, and the number of times is separated by ",". For example, the binary sequence "0001110011010100001100" is encoded as "12, 2, 2". Then perform Huffman coding, such as "1" is encoded as "101", "," is encoded as "00", and "2" is encoded as "11". The result is "1011100110011". That is, after encoding the above position information "13, 14", the key obtained is "1011100110011".
[0144] The data encryption method provided by the present invention can obtain the key of the encrypted target object by comparing the encrypted target object with the target object bit by bit and encoding the comparison result. The generated key can be used for subsequent decoding operations.
[0145] Based on any of the above embodiments, in this embodiment, selecting data from the target object to obtain a first data set and location information of each data in the first data set in the target object includes:
[0146] When the target object is an independent coding unit in a video bitstream, selecting the leading bytes of a specified length and coefficient residual information of a luminance block in an intra-frame prediction block from the independent coding unit to obtain a first data set;
[0147] According to the selected bytes and the position of the coefficient residual information of the luminance block in the intra-frame prediction block in the independent coding unit, the position information of each data in the first data set in the target object is obtained.
[0148] When the target object is an independent coding unit in a video bitstream, according to the characteristics of video coding, it can be known that in each independent coding area, since the encoding process highly compresses the video data, the data dependency in the compressed bitstream is enhanced, and each bit change will have a great impact on the subsequent bitstream decoding. Therefore, the first multiple bytes (such as 5 bytes) of each independent coding unit are of high importance. If these data are selected for encryption, the scope of influence can be expanded and the visual degradation of the encrypted video can be enhanced. In addition, considering that the decoding of the coding block in the inter-frame prediction mode depends on the coding block information of the intra-frame prediction. The human eye is more sensitive to the resolution of luminance information than chrominance information. Therefore, the coefficient residual information of the luminance block in the intra-frame prediction block can also be selected for encryption.
[0149] It should be noted that before extracting the frontmost bytes of the specified length and the coefficient residual information of the luminance block in the intra-frame prediction block from the independent coding unit, the independent coding unit needs to be entropy coded and parsed. Only after entropy coding and parsing can the required data be extracted.
[0150] Since the positions of the coefficient residual information of the selected bytes or luminance blocks in the coding unit are known, their position information can be obtained.
[0151] The data encryption method provided by the present invention realizes the selection of important data in the coding unit by selecting the bytes of the specified length at the front end of the independent coding unit and the coefficient residual information of the luminance block in the intra-frame prediction block, which helps to expand the impact range and enhance the visual degradation degree of the encrypted video.
[0152] Based on any of the above embodiments, in this embodiment, selecting data from the target object to obtain a first data set and location information of each data in the first data set in the target object includes:
[0153] In the case where the target object is an independent coding unit in a video code stream, all data are selected from the independent coding unit to obtain a first data set and position information of each data in the first data set in the target object.
[0154] In the previous embodiment, entropy coding analysis is performed on the independent coding units in the video code stream, and then the required data is selected therefrom. However, the entropy coding analysis process consumes a lot of time, so in this embodiment, for the purpose of improving efficiency, all the data in the independent coding units can also be used as the selected data to obtain the first data set.
[0155] The data in the first data set is actually the data in the target object, so the location information of the data itself is the location information of each data in the first data set in the target object.
[0156] The data encryption method provided by the present invention can avoid data analysis processes such as entropy coding and parsing by selecting all data in independent coding units, reduce time overhead, and help improve encryption efficiency.
[0157] Figure 2 The flowchart of the data decryption method provided by the present invention is as follows: Figure 2 As shown, the data decryption method provided by the present invention includes:
[0158] Step 201: Obtain an encrypted target object and a key of the encrypted target object.
[0159] The encrypted target object and the key of the encrypted target object described in this embodiment are obtained by using the data encryption method described in the previous embodiment. In the previous embodiment, their generation process has been described in detail, so it will not be repeated here.
[0160] For example, the encrypted target object obtained is a binary string "1100011011010110", and the key corresponding to the encrypted target object is "1011100110011".
[0161] Step 202: According to the key of the encrypted target object, obtain the position where the encrypted target object changes in value compared to the target object.
[0162] In the previous embodiment, when describing the key generation process, it has been mentioned that the key records the location of the data where the value of the encrypted target object changes compared with the original target object. Therefore, based on the key of the encrypted target object, the location where the value of the encrypted target object changes compared with the original target object can be obtained.
[0163] Based on the key of the encrypted target object, how to obtain the position where the encrypted target object changes value compared to the original target object is related to the key generation process. For example, if the key is encrypted when it is generated, it is necessary to perform a decryption operation on the key. The specific generation process is not limited in this embodiment.
[0164] For example, the aforementioned key "1011100110011" is obtained through binary run-length coding and entropy coding. By performing entropy decoding and binary run-length coding decoding on it, the position information "13, 14" can be obtained.
[0165] Step 203: According to the position where the value of the encrypted target object changes, the data of the corresponding bit in the encrypted target object is flipped to obtain the target object.
[0166] Since the data in the encrypted target object is represented in binary form, each data can only have two possible values, either 0 or 1. After obtaining the position where the value changes in the encrypted target object through the previous steps, the data of the corresponding bit can be found according to the position information. Since the possible values of the data are either 0 or 1, the correct value of the data can be obtained by flipping the data. Flipping all the data whose values have changed in the encrypted target object can obtain the original target object, that is, the target object before encryption.
[0167] For example, it is known that the encrypted target object is a binary string "1100011011011010", and the position where the value changes in the encrypted target object is "13, 14. The binary numbers of the 13th and 14th bits are flipped to obtain the binary string "1100011011010110". Compared with the original target object "1100011011010110", it is found that the two are the same, which proves that the decryption operation of the encrypted target object has been successfully completed.
[0168] The data decryption method provided by the present invention can obtain the positions where the encrypted target object changes value compared to the target object by decrypting the key, and perform data flipping operation on the encrypted target object according to these positions to generate the original target object. The method of the present invention has a faster decryption speed and a larger key space than the existing decryption method. Most of the keys in the prior art are based on traditional encryption algorithms, and the decryption process needs to use traditional encryption algorithms to regenerate the encryption sequence. The method of the present invention only needs to decode the key, which improves the decryption efficiency.
[0169] Based on any of the above embodiments, in this embodiment, obtaining the position where the encrypted target object changes in value compared to the target object according to the key of the encrypted target object includes:
[0170] Performing entropy decoding on the encrypted key of the target object to obtain a coding sequence;
[0171] The coding sequence is decoded by binary run-length coding to obtain a binary sequence; wherein the first value in the binary sequence indicates that the value of the corresponding position in the encrypted target object has changed compared with the value in the target object; and the second value in the binary sequence indicates that the value of the corresponding position in the encrypted target object has not changed compared with the value in the target object.
[0172] In this embodiment, a specific implementation of the decryption key is provided.
[0173] The key of the encrypted target object involved in this embodiment is obtained by performing binary run-length coding and entropy coding on the position information. Therefore, when decrypting the key, entropy decoding, such as Huffman decoding, is first performed to obtain a coding sequence, and then the coding sequence is decoded by binary run-length coding to obtain a binary sequence.
[0174] The data decryption method provided by the present invention obtains the position of the data whose value has changed in the encrypted target object by performing entropy decoding and binary run-length coding decoding on the key, and then can decrypt the encrypted target object.
[0175] A specific example of the present invention is provided below based on the H.265 / HEVC coding standard.
[0176] (1) First selection:
[0177] The H.265 encoder is transmitted in the network in the form of NAL units. Each NAL unit contains VPS, SPS, PPS parameter sets and compressed data of a Slice. A Slice contains one or more coding tree units CTU. Figure 3 This is a flowchart of the first selection process implemented in this embodiment. After the encoding is completed, the Slice Header and the first CTU data of each NAL unit are selected through the entropy coding process to obtain sensitive data D1 to expand the scope of influence. In addition to the first CTU, the coefficient residual information D2 of the luminance block encoded in the intra-frame prediction mode in the remaining CTU is selected to ensure that the key information in the bitstream is encrypted. The aforementioned sensitive data D1 and coefficient residual information D2 constitute the first data set.
[0178] (2) Second choice:
[0179] Random selection is mainly achieved using the RC4 pseudo-random sequence generator. Figure 4 This is a schematic diagram of data selection based on random sequence. Figure 4 As shown, 10 initial keys of length 128 bits are selected to generate 10 keys of length 2 15 bit pseudo-random sequence. rc4The 10 pseudo-random sequences are bitwise ANDed to form a random selection sequence Seq1, which is used to randomly select the code stream CS1 after the first selection. Then all 10 pseudo-random sequences are bitwise ANDed to form a random selection sequence Seq2, which is used to randomly select the code stream CS2 after the first selection. Divide the code stream CS1 into several 15 bit data block CS1′. Align the randomly selected sequence Seq1 with each data block CS1′. If a bit in the randomly selected sequence Seq1 is 1 at this time, the bit in the corresponding data block CS1′ is extracted. Similarly, the bits to be encrypted are extracted from the code stream CS2 after the first selection. All the extracted bits constitute the code stream CS3 after the second selection, that is, the second data set.
[0180] (3) Data obfuscation and data write-back:
[0181] In this embodiment, the RC4 pseudo-random sequence generator is used to generate a random number E3 of the same length as the bit stream CS3, which replaces the bit stream CS3 after the second selection to achieve the effect of data encryption. According to the position where the bit is 1 in the randomly selected sequence Seq1 and Seq2, the bit stream E3 is written back to the bit stream CS1 and CS2 one by one. Then, according to the bit stream analysis process, the position of the data is selected, and the bit streams CS1 and CS2 are written back to the original video bit stream to form an encrypted video bit stream.
[0182] (4) Generate algorithm key
[0183] Compare the encrypted video with the original video, record the bit position where flipping occurs as 1, and record the bit position where flipping does not occur as 0. Since the first bit of the video is the NAL unit header data, it is not extracted in the first selection. Therefore, flipping will definitely not occur, that is, the first bit of the position information must be 0. Run-length encoding is performed on the binary sequence. Since it is a binary code and the first bit value is determined, it is only necessary to record the number of consecutive occurrences of 0 or 1, with "," intervals between the numbers. This embodiment uses Huffman coding to perform secondary encoding on the result of run-length coding. The result of run-length coding is regarded as consisting of 11 states: "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" and ",", and the data is Huffman encoded according to the frequency of occurrence to form an algorithm key.
[0184] (5) Video decryption
[0185] Receive the encrypted position coding information transmitted by the key channel, perform Huffman decoding according to the code table, and then perform binary run-length coding decoding. According to the position information, flip the bit information in the encrypted video again to obtain the decrypted video.
[0186] (6) Performance analysis
[0187] Select four test videos: RaceHorses, PartyScene, Vidyo3, and Chinaspeed. For RaceHorses and PartyScene, let N rc4 = 5. For Vidyo3 and Chinaspeed, let N rc4 = 4. For this embodiment, the algorithm performance is analyzed from four perspectives: visual degradation, encryption security, encryption efficiency, and compression efficiency change.
[0188] a. Degree of visual degradation:
[0189] In this embodiment, an objective index can be used to measure the visual security of the encryption algorithm. Table 1 shows the peak signal-to-noise ratio (PSNR) and structural similarity (SSIM) of the video frames before and after encryption. It can be seen that the encrypted video frames have high visual security.
[0190] Table 1 Comparison of PSNR and SSIM before and after encryption
[0191] Test sequence PSNR SSIM RaceHorses 10.89 0.19 PartyScene 10.14 0.14 Vidyo3 10.86 0.27 Chinaspeed 7.24 0.16
[0192] b. Encryption security:
[0193] The key space of the algorithm is composed of the length L of the code stream of the encoded encrypted position information key For the above four test videos, Table 2 shows the encoding bitstream length L key Compared with the entire video data L video It can be seen that the length of the code stream is greater than 256 bits, so the key space Much larger than 2 256 , which is sufficient to resist exhaustive attacks.
[0194] Table 2 Key space analysis
[0195] Test sequence Key(bit) Key / Video(%) RaceHorses 41114 1.43 PartyScene 173356 1.09 Vidyo3 35672 0.72 Chinaspeed 139429 0.64
[0196] c. Encryption efficiency
[0197] Table 3 shows the running time of each step of the four videos tested and the proportion of the encoding time. It can be seen that the encryption time of this embodiment is only about 0.2%-0.4% of the encoding time, which has a very high encryption efficiency.
[0198] Table 3 Encryption efficiency analysis (unit: seconds)
[0199]
[0200] d. Changes in compression efficiency
[0201] Entropy coding is the last step of the entire video encoding process. The algorithm of this embodiment analyzes the information represented by each syntax element before entropy coding and traces its corresponding position in the bit stream after entropy coding, which does not affect the compression of video data. In the data obfuscation process, E3 is also the same length as CS3. Therefore, the length of the video bit stream remains unchanged before and after encryption. Table 4 shows the bit stream length before and after encryption of the test video, which shows that the algorithm of this embodiment does not affect the compression efficiency of the encoder.
[0202] Table 4 Comparison of code stream length before and after encryption
[0203]
[0204]
[0205] The data encryption device provided by the present invention is described below. The data encryption device described below and the data encryption method described above can be referenced to each other.
[0206] Figure 5 A schematic diagram of a data encryption device provided by the present invention, such as Figure 5 As shown, the data encryption device includes:
[0207] A first data selection module 501 is used to select data from a target object, obtain a first data set and location information of each data in the first data set in the target object;
[0208] A second data selection module 502 is used to generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain the position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object;
[0209] The obfuscation module 503 is used to perform an obfuscation operation on each data in the second data set to obtain a third data set, and obtain the position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object;
[0210] A write-back module 504, configured to write back each data in the third data set to the target object according to the location information of each data in the third data set in the target object, to obtain an encrypted target object;
[0211] The key generation module 505 is used to generate a key for the encrypted target object according to a comparison result between the target object and the encrypted target object.
[0212] The data encryption device provided by the present invention randomly selects data from the target object, performs an obfuscation operation on the selected data, and finally writes the obfuscated data back to the target object. This can reduce the amount of data encryption while ensuring the security of the data, thus achieving a good balance between security and efficiency.
[0213] Figure 6 A schematic diagram of a data decryption device provided by the present invention, such as Figure 6 As shown, the data decryption device comprises:
[0214] A receiving module 601 is used to receive the encrypted target object and the key of the encrypted target object obtained based on the data encryption device;
[0215] A position information acquisition module 602, for obtaining a position where a value of the encrypted target object changes compared to the target object according to the key of the encrypted target object;
[0216] The flip module 603 is used to flip the corresponding bits in the encrypted target object according to the positions where the values in the encrypted target object change, so as to obtain the target object.
[0217] The data decryption device provided by the present invention can obtain the positions where the encrypted target object has value changes compared to the target object by decrypting the key, and perform data flipping operations on the encrypted target object according to these positions to generate the original target object. The device of the present invention has a faster decryption speed and a larger key space than the existing decryption device. Most of the keys in the prior art are based on traditional encryption algorithms, such as RC4 mentioned in this example. The decryption process requires the use of the RC4 key to regenerate the encryption sequence. The device of the present invention only needs to decode the key, which improves the decryption efficiency.
[0218] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the data encryption method, which includes:
[0219] Selecting data from a target object to obtain a first data set and location information of each data in the first data set in the target object;
[0220] Generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object;
[0221] Performing an obfuscation operation on each data in the second data set to obtain a third data set, and obtaining position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object;
[0222] Writing each data in the third data set back to the target object according to the location information of each data in the third data set in the target object to obtain an encrypted target object;
[0223] A key for the encrypted target object is generated according to a comparison result between the target object and the encrypted target object.
[0224] or performing a data decryption method, the method comprising:
[0225] Acquire the encrypted target object and the key of the encrypted target object obtained based on the data encryption method;
[0226] According to the key of the encrypted target object, obtaining a position where the encrypted target object has a value change compared to the target object;
[0227] According to the position where the value change occurs in the encrypted target object, the corresponding bit position in the encrypted target object is flipped to obtain the target object.
[0228] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0229] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer can execute the data encryption method provided by the above methods, the method comprising:
[0230] Selecting data from a target object to obtain a first data set and location information of each data in the first data set in the target object;
[0231] Generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object;
[0232] Performing an obfuscation operation on each data in the second data set to obtain a third data set, and obtaining position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object;
[0233] Writing each data in the third data set back to the target object according to the location information of each data in the third data set in the target object to obtain an encrypted target object;
[0234] A key for the encrypted target object is generated according to a comparison result between the target object and the encrypted target object.
[0235] or performing a data decryption method, the method comprising:
[0236] Acquire the encrypted target object and the key of the encrypted target object obtained based on the data encryption method;
[0237] According to the key of the encrypted target object, obtaining a position where the encrypted target object has a value change compared to the target object;
[0238] According to the position where the value change occurs in the encrypted target object, the corresponding bit position in the encrypted target object is flipped to obtain the target object.
[0239] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the computer program is implemented to perform the above-mentioned data encryption method, the method comprising:
[0240] Selecting data from a target object to obtain a first data set and location information of each data in the first data set in the target object;
[0241] Generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object;
[0242] Performing an obfuscation operation on each data in the second data set to obtain a third data set, and obtaining position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object;
[0243] Writing each data in the third data set back to the target object according to the location information of each data in the third data set in the target object to obtain an encrypted target object;
[0244] A key for the encrypted target object is generated according to a comparison result between the target object and the encrypted target object.
[0245] or performing a data decryption method, the method comprising:
[0246] Acquire the encrypted target object and the key of the encrypted target object obtained based on the data encryption method;
[0247] According to the key of the encrypted target object, obtaining a position where the encrypted target object has a value change compared to the target object;
[0248] According to the position where the value change occurs in the encrypted target object, the corresponding bit position in the encrypted target object is flipped to obtain the target object.
[0249] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0250] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0251] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data encryption method, characterized in that: include: Selecting data from a target object to obtain a first data set and location information of each data in the first data set in the target object; Generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object; Performing an obfuscation operation on each data in the second data set to obtain a third data set, and obtaining position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object; Writing each data in the third data set back to the target object according to the location information of each data in the third data set in the target object to obtain an encrypted target object; A key for the encrypted target object is generated according to a comparison result between the target object and the encrypted target object.
2. The data encryption method according to claim 1, characterized in that: The generating a random sequence and selecting data from the first data set according to the random sequence to obtain a second data set includes: Generate a first random sequence according to a preset selection key, wherein the random numbers in the first random sequence present a power-law distribution or an exponential distribution within the interval [1, L]; wherein L is the data length of the data included in the first data set; According to the values of each random number in the first random sequence, data is selected from the first data set to obtain a second data set.
3. The data encryption method according to claim 2, characterized in that: The step of generating a first random sequence according to a preset selection key comprises: According to the preset selection key, a pseudo-random number R in the interval (0, 1) is generated based on a pseudo-random sequence generator. pse ; According to the data length L of the data contained in the first data set, calculate A plurality of random numbers showing a power-law distribution in the interval [1, L] are obtained, and the plurality of random numbers constitute a first random sequence; wherein ceil represents a rounding-up operation.
4. The data encryption method according to claim 3, characterized in that: The pseudo-random number R generated in the interval (0, 1) pse include: According to the importance of the data in the first data set, the generated pseudo-random number R in the interval (0, 1) is determined. pse The more important the data is, the more pseudo-random numbers R pse The greater the number.
5. The data encryption method according to claim 1, characterized in that: The generating a random sequence and selecting data from the first data set according to the random sequence to obtain a second data set includes: Dividing the data in the first data set into a plurality of groups according to the order of positions; According to the importance of the data in the group, a plurality of evenly distributed pseudo-random sequences are allocated to each of the plurality of groups; wherein the higher the importance of the data in the group, the smaller the number of the evenly distributed pseudo-random sequences corresponding to the group; Performing a bitwise AND operation on a plurality of uniformly distributed pseudo-random sequences corresponding to each group, to obtain a second random sequence corresponding to each group; Data is selected from each group according to the value of each random number in the second random sequence corresponding to each group, and the set of selected data is the second data set.
6. The data encryption method according to claim 1, characterized in that: The obfuscating operation is performed on each data in the second data set to obtain a third data set, including: Generate a third random sequence based on a pseudo-random sequence generator, wherein the data length of the third random sequence is equal to the data length of the data included in the second data set; The data in the second data set is replaced with a third random sequence to obtain a third data set.
7. The data encryption method according to claim 1, characterized in that: The step of generating a key of the encrypted target object according to a comparison result between the target object and the encrypted target object includes: Compare the encrypted target object with the target object bit by bit, record the changed bits as the first value, and record the unchanged bits as the second value, to obtain a binary sequence for recording the bit change; wherein the first value is one of the binary values, and the second value is another value in the binary value that is different from the first value; Performing binary run-length coding on the binary sequence to obtain a coded sequence; The encoding sequence is entropy encoded to obtain the encrypted key of the target object.
8. The data encryption method according to claim 1, characterized in that: The step of selecting data from the target object to obtain a first data set and location information of each data in the first data set in the target object includes: When the target object is an independent coding unit in a video bitstream, selecting the leading bytes of a specified length and coefficient residual information of a luminance block in an intra-frame prediction block from the independent coding unit to obtain a first data set; According to the selected bytes and the position of the coefficient residual information of the luminance block in the intra-frame prediction block in the independent coding unit, the position information of each data in the first data set in the target object is obtained.
9. The data encryption method according to claim 1, characterized in that: The step of selecting data from the target object to obtain a first data set and location information of each data in the first data set in the target object includes: In the case where the target object is an independent coding unit in a video code stream, all data are selected from the independent coding unit to obtain a first data set and position information of each data in the first data set in the target object.
10. A data decryption method, characterized in that: include: Obtaining an encrypted target object and a key of the encrypted target object obtained by the data encryption method according to any one of claims 1 to 9; According to the key of the encrypted target object, obtaining a position where the encrypted target object has a value change compared to the target object; According to the position where the value change occurs in the encrypted target object, the corresponding bit position in the encrypted target object is flipped to obtain the target object.
11. The data decryption method according to claim 10, characterized in that: The step of obtaining, according to the key of the encrypted target object, a position where the encrypted target object changes in value compared to the target object, comprises: Performing entropy decoding on the encrypted key of the target object to obtain a coding sequence; The coding sequence is decoded by binary run-length coding to obtain a binary sequence; wherein the first value in the binary sequence indicates that the value of the corresponding position in the encrypted target object has changed compared with the value in the target object; and the second value in the binary sequence indicates that the value of the corresponding position in the encrypted target object has not changed compared with the value in the target object.
12. A data encryption device, characterized in that: include: A first data selection module, used to select data from a target object, and obtain a first data set and location information of each data in the first data set in the target object; a second data selection module, configured to generate a random sequence, select data from the first data set according to the random sequence to obtain a second data set, and obtain position information of each data in the second data set in the target object based on the position information of each data in the first data set in the target object; an obfuscation module, configured to perform an obfuscation operation on each data in the second data set to obtain a third data set, and obtain position information of each data in the third data set in the target object based on the position information of each data in the second data set in the target object; A write-back module, used for writing each data in the third data set back to the target object according to the position information of each data in the third data set in the target object, so as to obtain an encrypted target object; The key generation module is used to generate a key of the encrypted target object according to a comparison result between the target object and the encrypted target object.
13. A data decryption device, characterized in that: include: A receiving module, used to receive the encrypted target object and the key of the encrypted target object obtained based on the data encryption device according to claim 12; A position information acquisition module, used for obtaining a position where the encrypted target object has a value change compared to the target object according to the key of the encrypted target object; The flip module is used to flip the corresponding bits in the encrypted target object according to the position where the value change occurs in the encrypted target object to obtain the target object.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the processor implements the steps of the data encryption method according to any one of claims 1 to 9, or implements the steps of the data decryption method according to claim 10 or 11.
15. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data encryption method according to any one of claims 1 to 9 are implemented, or the steps of the data decryption method according to claim 10 or 11 are implemented.
