Data encryption methods, devices, equipment and their storage media
By identifying and encrypting the front-end data of key data blocks in MP4 files, and using dynamically generated encrypted random sequences for obfuscation, the problem of low encryption efficiency in existing technologies is solved, achieving efficient and secure data encryption.
Patent Information
- Application Number
- CN202410015711.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-04
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2044-01-04
AI Technical Summary
Existing encryption methods for MP4 files are inefficient and cannot meet the needs of real-time communication.
By identifying the target data blocks and their locations in the MP4 file, key front-end data is selected as the target encrypted data, and a pre-defined obfuscation process is performed using an encrypted random sequence generated based on the attribute information of the data to be encrypted.
It effectively reduces the amount of encrypted data, improves encryption efficiency, enhances encryption security, and increases the difficulty of cracking.
Smart Images

Figure CN118827116B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and particularly relates to a data encryption method and device, equipment and a storage medium thereof. BACKGROUND
[0002] With the popularity of intelligent terminals and the rapid development of mobile internet technology, audio and video services consistently occupy a dominant position in the entire mobile network traffic. MP4 (Moving Picture Experts Group 4) as a mainstream multimedia file format can realize compression and encoding of audio data and video data, and has the advantages of high compatibility, high compression ratio and multi-functionality. At the same time, the content security problem of the MP4 file is increasingly concerned by mobile users. How to ensure the real-time secure transmission of MP4 audio and video data, and how to handle the contradiction between encryption efficiency and security of large-capacity data are particularly important in the big data application scenario.
[0003] The conventional encryption method of the MP4 file is to regard the file as a binary bit stream, and then directly encrypt all bytes. This way is highly secure, but for large data volume of MP4 files, the amount of encrypted data increases dramatically, which leads to reduced encryption efficiency and cannot meet the needs of real-time communication.
[0004] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY
[0005] The main purpose of the present application is to provide a data encryption method, device, equipment and storage medium, which aims to solve the technical problem of low encryption efficiency of the conventional encryption method.
[0006] To achieve the above purpose, the present application provides a data encryption method, which comprises:
[0007] determining a target data block in the data to be encrypted, wherein the target data block is at least one media data block in the data to be encrypted;
[0008] identifying a target position of target media data corresponding to the target data block in the data to be encrypted;
[0009] determining the first preset number of data before the target position in the data to be encrypted as target encryption data;
[0010] performing a preset confusion processing on the target encryption data in the data to be encrypted based on an encryption random sequence, to obtain encrypted data, wherein the encryption random sequence is a random sequence generated according to attribute information of the data to be encrypted.
[0011] Optionally, before the step of performing preset obfuscation processing on the target encrypted data in the data to be encrypted based on the encrypted random sequence, the method further comprises:
[0012] generating a dynamic root key according to attribute information of the data to be encrypted;
[0013] generating a static root key according to attribute information of a data sending end of the data to be encrypted;
[0014] generating the encrypted random sequence according to the dynamic root key and the static root key.
[0015] Optionally, the step of generating a dynamic root key according to attribute information of the data to be encrypted comprises:
[0016] generating the dynamic root key according to the attribute information of the data to be encrypted and a preset encryption algorithm, wherein the encryption algorithm comprises hash operation and / or group XOR.
[0017] Optionally, the step of generating the encrypted random sequence according to the dynamic root key and the static root key comprises:
[0018] generating an encryption key according to the dynamic root key and the static root key;
[0019] stamping a time stamp on the encryption key to generate the encrypted random sequence.
[0020] Optionally, the target data block comprises at least one intra-frame coded frame data block and at least one audio data block.
[0021] Optionally, before the step of performing preset obfuscation processing on the target encrypted data in the data to be encrypted based on the encrypted random sequence, the method further comprises:
[0022] generating a dynamic first root key and a dynamic second root key according to attribute information of the data to be encrypted;
[0023] generating the encrypted random sequence according to the dynamic first root key;
[0024] generating a normalized random sequence according to the dynamic second root key;
[0025] determining an encryption position in the data to be encrypted according to the normalized random sequence;
[0026] determining data in the data to be encrypted at the encryption position as the target encrypted data.
[0027] Optionally, the step of determining the encryption positions in the data to be encrypted according to the normalized random sequence comprises:
[0028] determining candidate positions according to a product between the normalized random sequence and a target difference value, wherein the target difference value is a difference between a total number of the target media data and the preset first number;
[0029] determining the first preset number of the candidate positions in the data to be encrypted as the encryption positions.
[0030] The present application also provides a data encryption device, which comprises:
[0031] a determining module configured to determine a target data block in data to be encrypted, wherein the target data block is at least one media data block in the data to be encrypted;
[0032] a recognizing module configured to recognize a target position of target media data corresponding to the target data block in the data to be encrypted;
[0033] the determining module is further configured to determine a first preset number of data located at the target position in the data to be encrypted as target encryption data;
[0034] a confusing module configured to perform a preset confusing process on the target encryption data in the data to be encrypted based on an encryption random sequence, to obtain encrypted data, wherein the encryption random sequence is a random sequence generated according to attribute information of the data to be encrypted.
[0035] The present application also provides an electronic device, which comprises a memory, a processor and a data encryption program stored in the memory and executable on the processor, and the data encryption program is configured to implement the steps of the above data encryption method.
[0036] The present application also provides a storage medium, which is a computer readable storage medium, and the computer readable storage medium stores a data encryption program, and the data encryption program is executed by a processor to implement the steps of the above data encryption method.
[0037] The application discloses a data encryption method, which comprises the following steps: determining at least one media data block in to-be-encrypted data as a target data block, and then identifying a target position of target media data corresponding to the target data block in the to-be-encrypted data; and then selecting a first preset number of data in the to-be-encrypted data according to the target position to determine the target encryption data, that is, data actually subjected to encryption processing in the to-be-encrypted data. Since the audio data and the video data in the MP4 file are subjected to compression encoding, the data in the same data block is highly correlated, the data dependency in the compressed code stream is enhanced, and the change of each bit will greatly affect the subsequent bit stream decoding. The front-end data of the MP4 file contains important information such as a header file, and once the front-end data is confused, the subsequent data is more difficult to decode. Therefore, the application selects the more sensitive and key front-end data, that is, the first preset number of media data containing the audio data and / or the video data, as the target encryption data. Since the target encryption data is the key front-end data in the to-be-encrypted data, in the case that the part of data is encrypted, the remaining data is difficult to decode, therefore, the encrypted data amount is effectively reduced without reducing the encryption security, thereby improving the encryption efficiency. Then, the target encryption data is subjected to preset confusion processing through an encryption random sequence generated based on attribute information of the to-be-encrypted data. Since the encryption random sequence is generated based on the attribute information (for example, the creation time and the length) of the to-be-encrypted data, the encryption random sequence dynamically changes according to different to-be-encrypted data, increases the cracking difficulty, and greatly improves the encryption security. BRIEF DESCRIPTION OF DRAWINGS
[0038] Figure 1 A structural schematic diagram of an electronic device related to a hardware running environment of an embodiment scheme of the application;
[0039] Figure 2 A flow schematic diagram of a data encryption method related to a first embodiment of the application;
[0040] Figure 3 A scene schematic diagram of a data encryption method related to the first embodiment of the application;
[0041] Figure 4 A flow schematic diagram of a data encryption method related to a second embodiment of the application;
[0042] Figure 5 A framework structural schematic diagram of a data encryption device related to the embodiment scheme of the application.
[0043] The implementation, functional features and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0044] It should be understood that the specific embodiments described herein are merely illustrative of the application and should not be used to limit the scope of the application.
[0045] In addition, the descriptions of "first", "second", etc. in the present application are only for the purpose of description, and cannot be understood as indicating or implying the relative importance of the technical features indicated, or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first", "second" can explicitly or implicitly include at least one of the features. In addition, "and / or" throughout the text includes three schemes, for example, A and / or B, including A technical scheme, B technical scheme, and A and B technical scheme that meet at the same time; in addition, the technical schemes of each embodiment can be combined with each other, but it must be based on the realization of ordinary skilled in the art, when the combination of technical schemes appears contradictory or unachievable, it should be considered that the combination of technical schemes does not exist, and is not within the scope of protection claimed by the present application.
[0046] Referring to Figure 1 , Figure 1 The electronic device structure schematic diagram of the hardware running environment involved in the embodiment of the present application.
[0047] As Figure 1 shown, the electronic device can include a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to realize the connection and communication between the components. The user interface 1003 can include a display screen (Display), an input unit such as a keyboard (Keyboard), and an optional user interface 1003 can also include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 can be a high-speed random access memory (RAM) memory, or a stable non-volatile memory (NVM), such as a magnetic disk memory. The memory 1005 can also be an independent storage device from the aforementioned processor 1001.
[0048] Those skilled in the art can understand that Figure 1 the structure shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than the figure, or combine certain components, or different component arrangements.
[0049] As Figure 1As shown, the memory 1005 as a storage medium can include an operating system, a data storage module, a network communication module, a user interface module, and a data encryption program.
[0050] In Figure 1 In the electronic device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the electronic device of the application can be arranged in the electronic device, and the electronic device calls the data encryption program stored in the memory 1005 through the processor 1001 and performs the following operations:
[0051] Determine the target data block in the data to be encrypted, wherein the target data block is at least one media data block in the data to be encrypted;
[0052] Identify the target location of the target media data corresponding to the target data block in the data to be encrypted;
[0053] Determine the first preset number of data located at the target location in the data to be encrypted as target encryption data;
[0054] Based on the encryption random sequence, the target encryption data in the data to be encrypted is subjected to a preset confusion processing to obtain encrypted data, wherein the encryption random sequence is a random sequence generated according to the attribute information of the data to be encrypted.
[0055] Further, the processor 1001 can call the data encryption program stored in the memory 1005 and further perform the following operations:
[0056] Before the operation of performing the preset confusion processing on the target encryption data in the data to be encrypted based on the encryption random sequence, further comprising:
[0057] Generating a dynamic root key according to the attribute information of the data to be encrypted;
[0058] Generating a static root key according to the attribute information of the data sending end of the data to be encrypted;
[0059] Generating the encryption random sequence according to the dynamic root key and the static root key.
[0060] Further, the operation of generating a dynamic root key according to the attribute information of the data to be encrypted comprises:
[0061] Generating the dynamic root key according to the attribute information of the data to be encrypted and a preset encryption algorithm, wherein the encryption algorithm includes hash operation and / or group XOR.
[0062] Further, the operation of generating the encrypted random sequence according to the dynamic root key and the static root key comprises:
[0063] generating an encryption key according to the dynamic root key and the static root key;
[0064] stamping a time on the encryption key to generate the encrypted random sequence.
[0065] Further, the target data block comprises at least one intra-frame coded frame data block and at least one audio data block.
[0066] Further, the processor 1001 can invoke the data encryption program stored in the memory 1005, and further perform the following operations:
[0067] Before the operation of performing the preset obfuscation processing on the target encryption data in the to-be-encrypted data based on the encrypted random sequence, further comprising:
[0068] generating a dynamic first root key and a dynamic second root key according to the attribute information of the to-be-encrypted data;
[0069] generating the encrypted random sequence according to the dynamic first root key;
[0070] generating a normalized random sequence according to the dynamic second root key;
[0071] determining an encryption position in the to-be-encrypted data according to the normalized random sequence;
[0072] determining the data in the to-be-encrypted data at the encryption position as the target encryption data.
[0073] Further, the operation of determining the encryption position in the to-be-encrypted data according to the normalized random sequence comprises:
[0074] determining a candidate position according to the product between the normalized random sequence and a target difference value, wherein the target difference value is the difference between the total number of the target media data and the preset first number;
[0075] determining the first preset number of the candidate positions as the encryption positions.
[0076] Based on the above structure, various embodiments of the data encryption method are proposed.
[0077] Reference is made to Figure 2 and 3 , Figure 2 the flowchart of the first embodiment of the data encryption method of the present application, Figure 3 the scenario diagram of the first embodiment of the data encryption method of the present application.
[0078] In the embodiment, the execution subject of the data encryption method can be an electronic device, which can be a local device or a network device. The electronic device can be a data sending end of the data to be encrypted, or a separate data encryption end. In the embodiment, the execution subject is not limited. The following is for the convenience of description, and the description of each embodiment is omitted. In the embodiment, the data encryption method includes:
[0079] In step S10, a target data block in the data to be encrypted is determined, wherein the target data block is at least one media data block in the data to be encrypted.
[0080] In an available embodiment, the data to be encrypted can be MP4 format data composed of multiple data blocks (boxes). In order to reduce the amount of encrypted data and improve encryption efficiency on the basis of ensuring data security, a part of key data can be selected from the data to be encrypted for encryption. Since the MP4 format is mainly applied to audio and video data, the audio and video data are the key data in the data to be encrypted. Further, at least one media data block in the data to be encrypted is determined as the target data block.
[0081] Optionally, the media data block is a trak data block (trak or stream container, a data block storing video / audio stream) whose type is audio or video, that is, the data stored in the mdat (media data) data block corresponding to the trak data block is audio or video.
[0082] For example, a box header in the data to be encrypted is searched, and an ASCII (American Standard Code for Information Interchange) code of a boxtype in the box header is identified. A data block with an ASCII code of 74 21 61 6B is determined as a trak data block. Further, a data block with an ASCII code of 68 646C 72 in the box header of the trak data block is determined as a hdlr (Handler Reference) data block. A handler type corresponding to the hdlr data block is read, so that the type of the trak data block is determined.
[0083] In an available embodiment, the target data block includes at least one intra-coded frame data block and at least one audio data block.
[0084] The intra-coded frame data block is an I-frame track data block, that is, the data stored in the mdat data block corresponding to the track data block is an I-frame (intra-coded frame).
[0085] The audio data block is an audio track data block, that is, the data stored in the mdat data block corresponding to the track data block is audio.
[0086] Optionally, the target data block can further include other frame data blocks in the data to be encrypted, such as P-frame (forward-predicted coded frame) track data blocks and / or B-frame (bidirectional reference frame) track data blocks.
[0087] Optionally, the target data block includes all intra-coded frame data blocks and audio data blocks in the data to be encrypted.
[0088] In this embodiment, since for video data, the I-frame belongs to a key frame and can be decoded alone, and the B-frame and the P-frame both need to be decoded according to the I-frame information. Therefore, once the I-frame is confused, the B / P-frame cannot be correctly decoded. Further, this embodiment selects the I-frame as the actual encrypted data, which can reduce the encrypted data amount on the basis of ensuring data security, thereby improving the encryption efficiency.
[0089] Step S20, identifying a target position of target media data corresponding to the target data block in the data to be encrypted;
[0090] In an available embodiment, the target position of the target media data corresponding to each target data block (that is, track data block) in the mdat data block of the data to be encrypted is identified.
[0091] For example, the stco (chunk offset) data block, that is, the data block with the ASCII code of 73 74 63 6F of the box header, is identified from the track data block; the offset of each target media data relative to the initial position of the file is determined according to the stco data block, to obtain the target position.
[0092] Step S30, determining the first preset amount of data before the target position in the data to be encrypted as target encrypted data;
[0093] In an available embodiment, after the position of the target media data in the data to be encrypted is determined, since the front-end data of the MP4 format data contains a header file and other important information, once confused, the subsequent data is difficult to decode; therefore, in order to further reduce the encrypted data amount, the first preset amount of data before each target position is determined as the target encrypted data.
[0094] Optionally, when there are multiple target data blocks, the target encrypted data is determined as the front preset first number of data at the target position corresponding to each target data block.
[0095] Optionally, the preset first number can be set according to actual needs, for example, the preset first number is 50 bytes. Since the front and rear data of the MP4 format data have strong correlation, the front end data (the front preset first number of data) in the target media data corresponding to each target data block is selected, so as to further reduce the encrypted data amount and improve the encryption efficiency.
[0096] Optionally, if the number of the target media data corresponding to the target data block is less than the preset first number, the target media data corresponding to the target data block is determined as the target encrypted data.
[0097] In step S40, the target encrypted data in the data to be encrypted is subjected to preset confusion processing based on an encrypted random sequence, to obtain encrypted data, wherein the encrypted random sequence is a random sequence generated according to the attribute information of the data to be encrypted.
[0098] In an available embodiment, the target encrypted data in the data to be encrypted is subjected to preset confusion processing using an encrypted random sequence generated according to the attribute information of the data to be encrypted, to obtain encrypted data, so as to realize encryption of the MP4 format data to be encrypted.
[0099] The preset confusion processing can be confusion encryption processing, and the confusion data is obtained by performing bitwise XOR operation on the encrypted random sequence and the target encrypted data.
[0100] In the embodiment, at least one media data block in the to-be-encrypted data is determined as a target data block, and then a target position of target media data corresponding to the target data block in the to-be-encrypted data is identified; and then, according to the target position, a first preset number of data selected from the to-be-encrypted data is determined as target encryption data, that is, data actually subjected to encryption processing in the to-be-encrypted data. Since the audio data and the video data in the MP4 file are both compressed and encoded, the data in the same data block is highly correlated, the data dependency in the compressed code stream is enhanced, and the change of each bit will greatly affect the decoding of the subsequent bit stream. Once the front-end data of the MP4 file, which contains important information such as a header file, is confused, the subsequent data is more difficult to decode. Therefore, the application selects the more sensitive and critical front-end data, that is, the first preset number of media data containing audio data and / or video data, as the target encryption data, effectively reduces the amount of encrypted data, and thus improves the encryption efficiency without reducing the encryption security. Then, the target encryption data is subjected to preset confusion processing based on an encryption random sequence generated based on the attribute information of the to-be-encrypted data. Since the encryption random sequence is generated based on the attribute information (for example, the creation time and the length) of the to-be-encrypted data, it will dynamically change according to different to-be-encrypted data, increase the cracking difficulty, and greatly improve the encryption security.
[0101] Further, based on the first embodiment, the second embodiment of the data encryption method of the application is proposed, in which Figure 4 Before the step of obtaining the encrypted data by performing preset confusion processing on the target encryption data in the to-be-encrypted data based on the encryption random sequence in step S40, the method further includes:
[0102] In step A10, a dynamic root key is generated based on the attribute information of the to-be-encrypted data.
[0103] In an available embodiment, in order to improve the encryption security of the data, a dynamic root key is generated based on the attribute information of the to-be-encrypted data. The dynamic root key can dynamically change according to the change of the to-be-encrypted data, so that when an attacker first steals the MP4 file, the attacker can also be prevented from further infringing by updating the dynamic root key.
[0104] Optionally, the dynamic root key is generated based on the attribute information of the trak data block in the to-be-encrypted data, that is, the data in the tkhd (track header, header of the data block storing the video / audio stream) data block of the trak data block, wherein the trak data block is any one or more trak data blocks of the type of audio or video; so that the generated dynamic root key is associated with the to-be-encrypted data.
[0105] The attribute information of the data to be encrypted can be the creation time and length of the data to be encrypted.
[0106] It should be understood that the data encryption method of the embodiment can be applied to various video encoders, audio codecs, and combined with various audio encoding standards, such as AAC (Advanced Audio Coding), AC3 (Audio Coding version 3), and video encoding standards, and can also be combined with any encryption algorithm.
[0107] In an implementation, the step A10 of generating the dynamic root key according to the attribute information of the data to be encrypted comprises:
[0108] The step A11 of generating the dynamic root key according to the attribute information of the data to be encrypted and a preset encryption algorithm, wherein the encryption algorithm comprises a hash operation and / or a block XOR.
[0109] Optionally, the length of the dynamic root key can be set according to actual needs, for example, a 256-bit dynamic root key.
[0110] For example, the data block with the ASCII code 74 6B 68 64 of the box header in the trak data block is determined as the tkhd data block, and then the data in the tkhd data block is read and converted into a dynamic root key by combining a hash operation and / or a block XOR.
[0111] Optionally, the attribute information of the data to be encrypted is input, and a hash value is output as the dynamic root key based on a hash operation.
[0112] The step A20 of generating the static root key according to the attribute information of the data sending end of the data to be encrypted;
[0113] In an implementation, the static root key is generated according to the attribute information of the data sending end of the data to be encrypted, for example, the identification number of the sending end, the basic information (user account, name, etc.) of the user at the time of registration, etc., wherein the static root key can change according to the change of the data sending end.
[0114] Optionally, the static root key of a preset length is randomly generated by combining the attribute information of the data sending end through a key generator, a hash operation and / or a block XOR, wherein the length of the static root key can be set according to actual needs, for example, 256 bits.
[0115] The step A30 of generating the encryption random sequence according to the dynamic root key and the static root key.
[0116] In an embodiment, the dynamic root key and the static root key are subjected to an exclusive OR operation to generate an encryption key; and the encryption random sequence is generated based on the encryption key.
[0117] In the embodiment, the static root key and the dynamic root key capable of being updated are respectively generated according to the attribute information of the data to be encrypted and the attribute information of the data sending end, and then the encryption random sequence is generated by combining the static root key and the dynamic root key, so that the encryption cracking difficulty is improved and the data security is improved.
[0118] In an embodiment, the step A30 of generating the encryption random sequence based on the dynamic root key and the static root key comprises:
[0119] The step A31 of generating an encryption key based on the dynamic root key and the static root key.
[0120] The step A32 of stamping a time stamp on the encryption key to generate the encryption random sequence.
[0121] In an embodiment, the dynamic root key and the static root key are subjected to an exclusive OR operation to obtain an encryption key; and then a time stamp is stamped on the encryption key, so that the encryption key is prevented from being tampered with, and the data security is further improved.
[0122] Further, based on the first and / or second embodiments, a third embodiment of the data encryption method of the application is proposed. In the embodiment, before the step S40 of performing a preset confusion processing on the target encryption data in the data to be encrypted based on the encryption random sequence to obtain the encrypted data, the method further comprises:
[0123] The step B10 of generating a dynamic first root key and a dynamic second root key based on the attribute information of the data to be encrypted.
[0124] The step B20 of generating the encryption random sequence based on the dynamic first root key.
[0125] The step B30 of generating a normalized random sequence based on the dynamic second root key.
[0126] In an embodiment, in order to further improve the data security, two dynamic root keys, i.e., a dynamic first root key and a dynamic second root key, can be generated based on the attribute information of the data to be encrypted; and then the encryption random sequence is generated based on the dynamic first root key, and the normalized random sequence is generated based on the dynamic second root key.
[0127] Optionally, according to the security protection level, a corresponding encryption method can be selected, for example, for data with a higher security protection level, the following steps are performed: generating the encryption random sequence according to the dynamic first root key; generating the normalized random sequence according to the dynamic second root key; and the subsequent steps. For data with a lower security protection level, the following steps are performed: generating the dynamic root key according to the attribute information of the data to be encrypted, and the subsequent steps. The selection of the encryption method can be actively selected by the user, or the security protection level of the data to be encrypted is automatically identified, and the corresponding encryption method is executed according to the target security protection level.
[0128] Optionally, the encryption random sequence is a binary random sequence, and the normalized random sequence is a sequence generated by a random number between 0 and 1.
[0129] Optionally, a static root key is generated according to the attribute information of the data sending end of the data to be encrypted; an encryption key is generated according to the dynamic first root key and the static root key; a timestamp is added to the encryption key to generate the encryption random sequence. A selection key is generated according to the dynamic second root key and the static root key; a timestamp is added to the selection key to generate the normalized random sequence.
[0130] Step B40, determining the encryption position in the data to be encrypted according to the normalized random sequence;
[0131] In a feasible implementation, step B40 of determining the encryption position in the data to be encrypted according to the normalized random sequence includes:
[0132] Step B41, determining the candidate position according to the product of the normalized random sequence and a target difference value, wherein the target difference value is the difference between the total number of the target media data and the preset first number;
[0133] In a feasible embodiment, if the total number of the target media data is greater than the preset first number, the difference between the total number of the target media data and the preset first number is calculated as the target difference value; the product of the target difference value and the normalized random sequence is calculated; and the candidate position is determined according to the product, starting from the position corresponding to the preset first number.
[0134] For example, the total number of the target media data is 80 bytes, the preset first number is 50 bytes, and the target difference value is 30; the normalized random sequence is {0.2354, 0.3421, 0.903}, and the product of the normalized random sequence and the target difference value is calculated to be {7, 10, 27}, wherein the decimal point after the product result is discarded; and the candidate positions are determined to be 57, 60 and 77, respectively, starting from the position corresponding to the preset first number.
[0135] Step B42, the first preset second number of candidate positions is determined as the encryption positions.
[0136] In an embodiment, the first preset second number of candidate positions is determined as the encryption positions.
[0137] Optionally, the preset second number can be calculated according to the target difference value and a preset proportion, for example, the preset proportion is 10%, the target difference value is 30, and the product between the target difference value and the preset proportion is determined as the preset second number, i.e. 3.
[0138] For example, the total number T of target media data is determined as size If T size is greater than the preset first number, the number of encryption data selected further is N se = (T size - preset first number) x preset proportion, and the selected positions are (T size - preset first number) x Pse2(i), i = 1, 2,..., N se , wherein Pse2(i) is a normalized random sequence.
[0139] Step B50, the data in the encryption positions in the data to be encrypted is determined as the target encryption data.
[0140] In an embodiment, in order to further improve data security, in addition to determining the first preset number of data in the target positions in the data to be encrypted as the target encryption data, the data in the encryption positions in the data to be encrypted is further determined as the target encryption data.
[0141] In this embodiment, in order to further improve data security, two dynamic root keys can be generated according to the attribute information of the data to be encrypted, and one of the dynamic root keys is used to generate a normalized random sequence; then the encryption positions are randomly selected from the data to be encrypted based on the normalized random sequence; the conventional scheme usually encrypts all the data in the mdat data block, while in this embodiment, the selection position of the encryption data is determined by the selection key through the normalized random sequence, the encryption position is blurred, and the encryption byte value is further increased, thereby improving the data security.
[0142] The application further provides a data decryption method, which is a reverse process of the encryption method; an encryption key is determined according to a dynamic root key and a static root key; a selection key can be further obtained for data with high encryption requirements; and a timestamp certificate is obtained to verify whether the key is tampered with. Then, target encrypted data is determined according to the selection key; and the target encrypted data is interfaced through the encryption key to obtain decrypted data.
[0143] Further, the application further provides a data encryption device, which is applied to an electronic device and comprises Figure 5 , wherein the data encryption device comprises:
[0144] A determination module 10 is configured to determine target data blocks in to-be-encrypted data, wherein the target data blocks are at least one media data block in the to-be-encrypted data.
[0145] An identification module 20 is configured to identify target positions of target media data corresponding to the target data blocks in the to-be-encrypted data.
[0146] The determination module 10 is further configured to determine data located in front of the target positions in the to-be-encrypted data by a preset first quantity as target encrypted data.
[0147] An obfuscation module 30 is configured to perform a preset obfuscation process on the target encrypted data in the to-be-encrypted data based on an encryption random sequence to obtain encrypted data, wherein the encryption random sequence is a random sequence generated according to attribute information of the to-be-encrypted data.
[0148] Optionally, the obfuscation module 30 is further configured to generate a dynamic root key according to the attribute information of the to-be-encrypted data; generate a static root key according to attribute information of a data sending end of the to-be-encrypted data; and generate the encryption random sequence according to the dynamic root key and the static root key.
[0149] Optionally, the obfuscation module 30 is further configured to generate the dynamic root key according to the attribute information of the to-be-encrypted data and a preset encryption algorithm, wherein the encryption algorithm comprises hash operation and / or group XOR.
[0150] Optionally, the obfuscation module 30 is further configured to generate an encryption key according to the dynamic root key and the static root key; and stamp the encryption key with a timestamp to generate the encryption random sequence.
[0151] Optionally, the obfuscation module 30 is further configured to generate a dynamic first root key and a dynamic second root key according to attribute information of the data to be encrypted; generate the encrypted random sequence according to the dynamic first root key; generate a normalized random sequence according to the dynamic second root key; determine an encryption position in the data to be encrypted according to the normalized random sequence; and determine data at the encryption position in the data to be encrypted as the target encrypted data.
[0152] Optionally, the obfuscation module 30 is further configured to determine a candidate position according to a product of the normalized random sequence and a target difference value, wherein the target difference value is a difference between a total number of the target media data and the preset first number; and determine a first preset number of the candidate positions as the encryption positions.
[0153] The data encryption device specific embodiments of the present application are basically the same as the above-mentioned data encryption method embodiments, and will not be described here again.
[0154] It should be noted that in this paper, the term "include", "contain" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or system including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or system. Without more limitations, the element defined by the sentence "including a" does not exclude the presence of other identical elements in the process, method, article or system including the element.
[0155] From the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be realized by means of software and general hardware platform as necessary, of course, they can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a plurality of instructions for making a terminal device (which can be a mobile phone, computer, server, or network device, etc.) execute the methods described in various embodiments of the present application.
[0156] The above is only the preferred embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent structure or equivalent process transformation made by using the contents of the specification and drawings, or directly or indirectly applied to other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A data encryption method, characterized in that, The method includes: Identify a target data block in the data to be encrypted, wherein the target data block is at least one media data block in the data to be encrypted; Identify the target location of the target media data corresponding to the target data block within the data to be encrypted; The first preset number of data points located at the target position in the data to be encrypted are determined as the target encrypted data; Based on an encrypted random sequence, the target encrypted data in the data to be encrypted is subjected to a preset obfuscation process to obtain encrypted data, wherein the encrypted random sequence is a random sequence generated based on the attribute information of the data to be encrypted.
2. The data encryption method as described in claim 1, characterized in that, Before the step of performing a preset obfuscation process on the target encrypted data in the data to be encrypted based on an encrypted random sequence, the method further includes: A dynamic root key is generated based on the attribute information of the data to be encrypted; A static root key is generated based on the attribute information of the data sender of the data to be encrypted; The encrypted random sequence is generated based on the dynamic root key and the static root key.
3. The data encryption method as described in claim 2, characterized in that, The step of generating a dynamic root key based on the attribute information of the data to be encrypted includes: The dynamic root key is generated based on the attribute information of the data to be encrypted and the preset encryption algorithm, wherein the encryption algorithm includes: hash operation and / or block XOR.
4. The data encryption method as described in claim 2, characterized in that, The step of generating the encrypted random sequence based on the dynamic root key and the static root key includes: An encryption key is generated based on the dynamic root key and the static root key; The encryption key is timestamped to generate the encrypted random sequence.
5. The data encryption method as described in claim 1, characterized in that, The target data block includes at least one intra-frame coded frame data block and at least one audio data block.
6. The data encryption method as described in claim 1, characterized in that, Before the step of performing a preset obfuscation process on the target encrypted data in the data to be encrypted based on an encrypted random sequence, the method further includes: Based on the attribute information of the data to be encrypted, a dynamic first root key and a dynamic second root key are generated; The encrypted random sequence is generated based on the dynamic first root key; Generate a normalized random sequence based on the dynamic second root key; Based on the normalized random sequence, determine the encryption position in the data to be encrypted; The data located at the encryption position in the data to be encrypted is determined as the target encrypted data.
7. The data encryption method as described in claim 6, characterized in that, The step of determining the encryption position in the data to be encrypted based on the normalized random sequence includes: Candidate positions are determined based on the product between the normalized random sequence and the target difference value, wherein the target difference value is the difference between the total number of target media data and the preset first number; The first, second number of candidate positions are selected as the encrypted positions.
8. A data encryption device, characterized in that, The device includes: A determining module is used to determine a target data block in the data to be encrypted, wherein the target data block is at least one media data block in the data to be encrypted; The identification module is used to identify the target location of the target media data corresponding to the target data block in the data to be encrypted; The determining module is further configured to determine the first preset number of data located at the target position in the data to be encrypted as the target encrypted data; The obfuscation module is used to perform preset obfuscation processing on the target encrypted data in the data to be encrypted based on an encrypted random sequence to obtain encrypted data, wherein the encrypted random sequence is a random sequence generated according to the attribute information of the data to be encrypted.
9. An electronic device, characterized in that, The device includes: a memory, a processor, and a data encryption program stored in the memory and executable on the processor, the data encryption program being configured to implement the steps of the data encryption method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and the storage medium stores a data encryption program, which, when executed by a processor, implements the steps of the data encryption method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Data encryption processing method and device, computer equipment and storage medium
CN113364760A
Data encryption method, data decryption method and door lock system
CN115909560A