Video data encryption method and device and computer equipment
By splitting video data frame by frame, generating keys and chaotic sequences, and DNA encoding, the problem of low security in private clouds is solved, and video data protection with fast encryption speed and high security is achieved.
Patent Information
- Application Number
- CN202510230852.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-06-03
AI Technical Summary
The security of image data in private clouds is low, and the encryption speed of traditional encryption methods is slow, making it difficult to withstand exhaustive attacks, and the encrypted data capacity affects transmission.
By obtaining the original video data to be encrypted, splitting it into multiple frames of image data frame by frame, generating multiple keys and generating chaotic sequences, DNA encoding of the keys and images are respectively DNA encoding, and encrypted video data is generated by combining chaotic sequences and DNA encoding.
The technical effect of improving the security of video data is achieved, the security of image data is improved, and the speed and capacity problems of traditional encryption methods are avoided.
Smart Images

Figure CN120091163A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information security technology, and more particularly, to a video data encryption method, apparatus, and computer device. Background Art
[0002] With the development of cloud computing technology, the problem of data security in private clouds has become increasingly prominent. As one of the important data types, the security and privacy protection of image data are particularly crucial. Traditional encryption methods are not fast enough in encryption speed, difficult to withstand brute-force attacks, the capacity of encrypted image data is too large to affect transmission, and the complexity and security of encryption cannot meet the security requirements of image data in private clouds. Summary of the Invention
[0003] Embodiments of this application provide a video data encryption method, apparatus, and computer device to at least solve the technical problem of low security of image data in private clouds in related technologies.
[0004] According to one aspect of the embodiments of this application, a video data encryption method is provided, including: obtaining original video data to be encrypted, and splitting the original video data to be encrypted frame by frame to obtain multiple frames of image data; generating multiple keys according to the multiple frames of images, and generating a chaotic sequence according to the keys; respectively performing DNA encoding on the multiple keys and the multiple frames of images to obtain multiple DNA-encoded key matrices and DNA-encoded sequences; generating encrypted video data according to the chaotic sequence, the DNA-encoded key matrices, and the DNA-encoded sequences.
[0005] Optionally, performing DNA encoding on the multiple frames of images to obtain a DNA-encoded sequence includes: respectively obtaining the RGB values of all pixel points in each frame of image, and converting the RGB values of all pixel points into a binary format; converting the RGB values in binary format of each pixel point into a DNA-encoded sequence according to a preset DNA dictionary, where the preset DNA dictionary includes a mapping relationship between binary codes and multiple bases of DNA.
[0006] Optionally, converting the RGB values in binary format of each pixel point into a DNA-encoded sequence includes: splitting the RGB values in binary format of each pixel point into multiple binary codes; respectively converting the multiple binary codes according to the DNA dictionary to obtain the DNA-encoded sequence.
[0007] Optionally, DNA encoding is performed on the multiple keys to obtain a plurality of DNA-encoded key matrices, including: converting the RGB value of each pixel into byte data, and using a hash algorithm to convert the byte data into a hash value; converting the hash value into a hexadecimal string to obtain a key; converting the key into an integer, and then converting the integer into a binary string, where the length of the binary string is 256 bits; filling the binary string of each pixel into an initial matrix to obtain the key matrix, and the shape of the initial matrix is the same as the shape of the color channel array of the multi-frame image; concatenating the first element of the current row in the key matrix and the second element adjacent to the first element into a target string; obtaining the DNA base value corresponding to the target string in a preset dictionary, and storing the DNA base value corresponding to the target string in the preset dictionary in the specified column of the current row of the DNA-encoded key matrix.
[0008] Optionally, generating a chaotic sequence according to the key, including: splitting the binary string corresponding to the key into multiple segments of a fixed length; dividing the multiple segments into three parts, where exclusive OR operations are respectively performed on the segments of each part to obtain three exclusive OR operation results; respectively converting the three exclusive OR operations into three floating-point numbers, and respectively using the three floating-point data to update the parameters of the chaotic system; generating the chaotic sequence by using the chaotic system with updated parameters, and each element in the chaotic sequence is used to represent the solution of the chaotic system in the X-axis, Y-axis, and Z-axis directions at each time point.
[0009] Optionally, generating encrypted video data according to the chaotic sequence, the DNA-encoded key matrix, and the DNA encoding sequence, including: using a sorting function to sort each element in the chaotic sequence, and generating an index array according to the sorted chaotic sequence, where the index array is used to represent the position of each element in the sorted chaotic sequence; performing an exclusive OR operation on each element at each position in the DNA encoding sequence corresponding to each color channel and the element at the corresponding position in the DNA-encoded key matrix to obtain an exclusive OR result; using the index array to scramble the exclusive OR result to obtain a scrambled exclusive OR result. Converting the scrambled exclusive OR result into a DNA encoding result according to the DNA dictionary, and determining the DNA encoding result as the encrypted video data.
[0010] Optionally, using the index array to scramble the exclusive OR result to obtain a scrambled exclusive OR result, including: flattening the exclusive OR result into a one-dimensional array; rearranging each element in the one-dimensional array in the order of the index array to obtain the scrambled exclusive OR result.
[0011] Optionally, the method further includes: decoding the encrypted video data to obtain decoded color values corresponding to each color channel; storing two elements corresponding to the decoded color values at adjacent positions in the decoded binary array; packing the decoded binary array in the column direction to obtain a packed array, where each element in the packed array represents the color channel value of a pixel point; generating a decrypted image according to the packed array.
[0012] According to another aspect of the embodiments of the present application, there is also provided a video data encryption device, including: an acquisition module, configured to acquire original video data to be encrypted, and split the original video data to be encrypted frame by frame to obtain multiple frames of image data; a first generation module, configured to generate multiple keys according to the multiple frames of images, and generate a chaotic sequence according to the keys; an encoding module, configured to perform DNA encoding on the multiple keys and the multiple frames of images respectively to obtain multiple DNA-encoded key matrices and DNA-encoded sequences; a second generation module, configured to generate encrypted video data according to the chaotic sequence, the DNA-encoded key matrices, and the DNA-encoded sequences.
[0013] According to yet another aspect of the embodiments of the present application, there is also provided a computer device, including: a memory and a processor, where the memory is used to store program instructions; the processor is connected to the memory and is configured to execute the above video data encryption method.
[0014] According to still another aspect of the embodiments of the present application, there is also provided a non-volatile storage medium, which includes a stored computer program, where the device where the non-volatile storage medium is located executes the above video data encryption method by running the computer program.
[0015] According to still another aspect of the embodiments of the present application, there is also provided a computer program product, including computer instructions, where when the computer instructions are executed by a processor, the above video data encryption method is implemented.
[0016] In the embodiment of the present application, by obtaining the original video data to be encrypted and splitting the original video data to be encrypted frame by frame, multiple frames of image data are obtained; multiple keys are generated according to the multiple frames of images, and a chaotic sequence is generated according to the keys; the multiple keys and the multiple frames of images are respectively subjected to DNA encoding to obtain multiple DNA-encoded key matrices and DNA-encoded sequences; the encrypted video data is generated according to the chaotic sequence, the DNA-encoded key matrix and the DNA-encoded sequence, thereby achieving the purpose of jointly generating the encrypted video data according to the chaotic sequence, DNA encoding and the keys, thereby realizing the technical effect of improving the security of video data, and further solving the technical problem of low security of image data in the private cloud in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0018] Figure 1 is a hardware structure block diagram of a computer terminal for implementing a video data encryption method according to an embodiment of the present application;
[0019] Figure 2 is a flowchart of a video data encryption method according to an embodiment of the present application;
[0020] Figure 3 is a flowchart of another video data encryption method according to an embodiment of the present application;
[0021] Figure 4 is a structural diagram of a video data encryption device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0023] It should be noted that the terms "first", "second", etc. in the description, claims, and the above-mentioned drawings of this application are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0024] The information collected in the embodiments of this application is information and data authorized by the user or fully authorized by all parties. Moreover, for the processing of relevant data such as collection, storage, use, processing, transmission, provision, disclosure, and application, all comply with the relevant laws, regulations, and standards of the relevant region, necessary confidentiality measures are taken, it does not violate public order and good customs, and a corresponding operation entry is provided for the user to choose to authorize or reject the automated decision-making result; if the user chooses to reject, the expert decision-making process will be entered.
[0025] To solve the problems existing in the related art, the embodiments of this application provide a video data encryption method, which can run on Figure 1 the computer terminal shown below, and the following is an explanatory description of this computer terminal.
[0026] The video data encryption method embodiments provided by the embodiments of this application can be executed on a mobile terminal, a computer terminal, or a similar computing device. Figure 1 The following shows a hardware structure block diagram of a computer terminal for implementing the video data encryption method. As Figure 1 shown, the computer terminal 10 may include one or more (shown as 102a, 102b,..., 102n in the figure) processors (the processor may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions connected by wired and / or wireless networks. In addition, it may further include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown in the figure, or have the same asFigure 1 The different configurations shown.
[0027] It should be noted that one or more of the above-mentioned processors and / or other data processing circuits can generally be referred to as "data processing circuits" herein. The data processing circuit can be embodied in software, hardware, firmware, or any combination thereof, in whole or in part. In addition, the data processing circuit can be a single independent processing module, or be incorporated in whole or in part into any one of other elements in the computer terminal 10. As involved in the embodiments of the present application, the data processing circuit is a kind of processor control (such as the selection of a variable resistance terminal path connected to an interface).
[0028] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the video data encryption method in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above-mentioned video data encryption method. The memory 104 can include high-speed random access memory, and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 can further include a memory remotely set relative to the processor, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above-mentioned network include but are not limited to the Internet, enterprise intranets, local area networks, mobile communication networks, and combinations thereof.
[0029] The transmission module 106 is used to receive or send data via a network. Specific examples of the above-mentioned network can include the wireless network provided by the communication provider of the computer terminal 10. In one instance, the transmission module 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission module 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0030] The display can be, for example, a touch-screen liquid crystal display (LCD), which enables the user to interact with the user interface of the computer terminal 10.
[0031] It should be noted here that in some alternative embodiments, the above Figure 1 shown computer terminal can include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware elements and software elements. It should be pointed out that Figure 1This is just an example of a specific concrete instance and is intended to show the types of components that may exist in the above computer terminal.
[0032] Under the above operating environment, an embodiment of a video data encryption method is provided in an embodiment of the present application. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. And, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0033] Figure 2 is a flowchart of a video data encryption method according to an embodiment of the present application, as Figure 2 shown, the method includes the following steps:
[0034] Step S202, obtain the original video data to be encrypted, and split the original video data to be encrypted frame by frame to obtain multiple frames of image data;
[0035] Step S204, generate multiple keys according to the multiple frames of images, and generate a chaotic sequence according to the keys;
[0036] In step S204, the chaotic sequence is generated by using a chaotic system, such as: Lorenz system.
[0037] Step S206, perform DNA encoding on the multiple keys and the multiple frames of images respectively to obtain multiple DNA-encoded key matrices and DNA-encoded sequences;
[0038] In step S206, DNA encoding refers to the technology of using specific sequences of DNA molecules to store, transmit or represent information. DNA encoding utilizes the characteristics of DNA molecules such as high stability, high density and biocompatibility, and has wide applications in fields such as data storage and biometric identification.
[0039] Step S208, generate encrypted video data according to the chaotic sequence, the DNA-encoded key matrix and the DNA-encoded sequence.
[0040] Through the above steps S202 to S208, by obtaining the original video data to be encrypted and splitting the original video data to be encrypted frame by frame, multiple frames of image data are obtained; multiple keys are generated according to the multiple frames of images, and a chaotic sequence is generated according to the keys; the multiple keys and the multiple frames of images are respectively subjected to DNA encoding to obtain multiple DNA-encoded key matrices and DNA encoding sequences; the encrypted video data is generated according to the chaotic sequence, the DNA-encoded key matrix and the DNA encoding sequence, thereby achieving the purpose of jointly generating the encrypted video data according to the chaotic sequence, DNA encoding and the key, thus realizing the technical effect of improving the security of video data, and further solving the technical problem of low security of image data in the private cloud in the related art. The following is a detailed description.
[0041] It should be noted that before encrypting the original video data, the original video data also needs to be preprocessed. Specifically, for the original video data selected from the private cloud, check whether the storage path of the original video data is empty. If the storage path is not empty, it is determined that the original video data is valid and the image can be loaded normally; if it is empty, it means that the selection may have been cancelled or the format is incorrect, and the result is informed to the user. The storage path of the original video data is obtained by performing a preprocessing operation on the original video data, and each frame of the original video data read is split, corresponding to the red color channel, the green color channel and the blue color channel respectively, and the 8-bit color channel values of each pixel point in each frame of the image are split into separate bit-level representations.
[0042] The specific splitting process is as follows: Read the image to be split. This image consists of three color channels: red, green, and blue, and each channel contains pixel values that describe the color information of each point in the image. Separate the image to be split into three independent two-dimensional arrays of red, green, and blue, and each array represents the pixel values of the corresponding color channel in the image.
[0043] Split the 8-bit binary value (used to represent an integer between 0 and 255) of each color channel of each pixel point in the image to be split bit by bit, and split the value of each color channel of each pixel point into separate bits.
[0044] In some embodiments of the present application, the specific steps for performing DNA encoding on the multiple frames of images to obtain a DNA encoding sequence are as follows: respectively obtain the RGB values of all pixel points in each frame of the image, and convert the RGB values of all pixel points into binary format; convert the binary-format RGB values of each pixel point into a DNA encoding sequence according to a preset DNA dictionary, and the preset DNA dictionary contains the mapping relationship between binary encoding and multiple bases of DNA.
[0045] Among them, converting the RGB value in binary format of each pixel point into a DNA coding sequence according to a preset DNA dictionary includes: splitting the RGB value in binary format of each pixel point into multiple binary codes; respectively converting the multiple binary codes according to the DNA dictionary to obtain the DNA coding sequence.
[0046] Taking the four bases of DNA, A (adenine), T (thymine), C (guanine), and G (cytosine) as an example, convert the color channel values of each pixel point in each frame of image according to the mapping relationship between the binary codes in the DNA dictionary and the multiple bases of DNA. For example: 00 corresponds to A, 01 corresponds to T, 10 corresponds to G, and 11 corresponds to C. For example, the DNA coding of the pixel point (128, 64, 32) may be: Red (R) channel: AT G C AT G C AT G C AT G C AT G C AT G C AT GC AT G C AT G C AT G Green (G) channel: AT G C AT G C AT G C AT G C AT G C AT G C ATG C AT G C AT G CA T G Blue (B) channel: A T G C A T G C AT G C AT G C AT G C AT G CAT G C AT GC AT G C AT G.
[0047] The specific conversion steps are as follows: Step 1: Decompose the original video data into individual image frames frame by frame; Step 2: Extract RGB channel data For each frame of image, extract the pixel values of its three color channels, red (R), green (G), and blue (B). Store these pixel values as a two-dimensional array, where each array element corresponds to a pixel point in the image frame; Step 3: Binary conversion Convert the pixel values of the color channels of each pixel point into binary representation. For example, 255 is converted to "11111111"; Step 4: Establish a mapping from binary to DNA bases Define a dictionary or mapping table (DNA dictionary) to map binary bit pairs to the four bases of DNA; Step 5: DNA coding Traverse the binary representation of each pixel point, take two binary bits each time, and replace them with the corresponding DNA bases according to the previously defined DNA dictionary. This process needs to be performed separately for the red, green, and blue color channels of the image. Store the converted DNA base sequence in a new array or list for subsequent use; Step 6: Pair the RGB channels and DNA coding For each channel (R, G, B), create a corresponding DNA coding array. Pair the binary values of the RGB channels with the DNA coding array for use in subsequent encryption operations.
[0048] In some embodiments of the present application, DNA encoding is performed on the multiple keys to obtain multiple DNA-encoded key matrices, including: converting the RGB values of each pixel into byte data, and using a hash algorithm to convert the byte data into a hash value; converting the hash value into a hexadecimal string to obtain a key; converting the key into an integer, and then converting the integer into a binary string, where the length of the binary string is 256 bits; filling the binary string of each pixel into an initial matrix to obtain the key matrix, and the shape of the initial matrix is the same as the shape of the color channel array of the multi-frame image; concatenating the first element of the current row in the key matrix and the second element adjacent to the first element into a target string; obtaining the DNA base value corresponding to the target string in a preset dictionary, and storing the DNA base value corresponding to the target string in the preset dictionary in the specified column of the current row of the DNA-encoded key matrix.
[0049] It can be understood that the RGB value refers to the values of the three color components of red, green, and blue.
[0050] Specifically, establish a pixel value list: traverse each pixel of the image frame to obtain the values of its RGB components. For each pixel, the values of the three RGB components (each component is an integer from 0 to 255) will be added to a list. For example, if the RGB value of a certain pixel in the image is (120, 155, 200), then 120, 155, and 200 will all be added to the list; create a SHA-256 hash object: in Python, you can use the sha256 function in the hashlib library to create a hash object. This object will be used to convert the pixel value list into an irreversible hash value, thereby generating a key. Update the hash object: convert the pixel value list into a byte array; generate a hash key: once the RGB values of all pixels have been added to the hash object and its internal state has been updated, a key string can be generated from the hash object.
[0051] The specific encoding process is as follows: Encode the hexadecimal key string key into a two-dimensional character key matrix. The key is converted into an integer and then into a binary string. If the length of the binary representation of the key is less than 256 bits, zeros are padded in front of it to create a zero key matrix Mk with the same shape (number of rows and columns) as the two-dimensional array of color channels, ensuring that the size of the key is consistent with the image data and used to store the binary representation of the key. Use the binary string of the key to fill the key matrix Mk. Since the binary key string may be longer than the size of Mk, modulo 256 is used to ensure that the index is within the valid range of the binary string. Take the i-th and i + 1-th elements (the i-th element and the i + 1-th element represent two binary bits respectively) of the current row from the Mk matrix, format them into a string, and look up the corresponding DNA base value in the DNA dictionary using this string as the key. Then, store this DNA base value in the current row and the specified column of the encoded key matrix.
[0052] It should be noted that the i-th element is the first element and the i + 1-th element is the second element. The specified column is the pre-determined storage location.
[0053] In some embodiments of the present application, the specific steps for generating a chaotic sequence according to the key include: splitting the binary string corresponding to the key into multiple segments of a fixed length; dividing the multiple segments into three parts, and respectively performing an exclusive OR operation on the segments of each part to obtain three exclusive OR operation results; respectively converting the three exclusive OR operations into three floating-point numbers, and respectively using the three floating-point data to update the parameters of the chaotic system; generating the chaotic sequence using the chaotic system with updated parameters, and each element in the chaotic sequence is used to represent the solution of the chaotic system in the X-axis, Y-axis, and Z-axis directions at each time point.
[0054] For example: The initial parameters of the chaotic system are x0, y0, z0 respectively. The binary key string is sliced into segments of every 8 characters (1 byte), and these segments are stored in the dictionary K with keys such as "k1", "k2", etc. Calculate the exclusive OR results of the 1st to 11th key parts ("k1" to "k11"), the 12th to 22nd key parts, and the 23rd to 32nd key parts respectively, and use them to update the parameters x0, y0, z0 of the Lorenz system respectively.
[0055] Specifically, the update of parameter x: First, we extract the first 11 key segments from the k dictionary, and the corresponding keys are "k1" to "k11". Then, we perform an XOR operation on the integer representations of these 11 segments. The result of the XOR operation will be converted into a floating-point number, that is, the value obtained by dividing by 256, and is used to update the initial parameter x0 of the Lorenz system. Specifically, the new value of x0 is equal to the original x0 value plus the floating-point number obtained by the XOR operation. Update of parameter y: Similarly, we extract the 12th to 22nd key segments, that is, the segments with keys "k12" to "k22", perform an XOR operation on the integer representations of these segments, and then divide by 256 to obtain a floating-point number. This newly obtained floating-point number will be used to update the initial parameter y0 of the Lorenz system, that is, the new value of y0 is equal to the original y0 value plus the result of the XOR operation as a floating-point number. Update of parameter z0: Finally, we take the 23rd to 32nd key segments, that is, the segments with keys "k23" to "k32", perform the same XOR operation and floating-point conversion, and use the result to update the initial parameter z0 of the Lorenz system. The new value of z0 is equal to the original z0 value plus the floating-point number obtained by dividing the result of the XOR operation by 256. XOR calculation and floating-point conversion:
[0056] The XOR operation is a binary logical operation, which ensures that even a small change in the key can produce a significant difference in the XOR result, thus affecting the initial state of the chaotic system. After calculating the XOR result, we convert it into a floating-point number, usually by dividing by 256. This is because the maximum value of each byte (i.e., an 8-bit binary number) is 255, so dividing by 256 can convert the XOR result into a floating-point number between 0 and 1, which is suitable for updating the initial parameters of the chaotic system.
[0057] In some embodiments of the present application, the specific method for generating the encrypted video data according to the chaotic sequence, the DNA-encoded key matrix, and the DNA-encoded sequence is as follows: Use a sorting function to sort each element in the chaotic sequence, and generate an index array according to the sorted chaotic sequence. The index array is used to represent the position of each element in the sorted chaotic sequence; Perform an XOR operation on the elements at each position in the DNA-encoded sequence corresponding to each color channel and the elements at the corresponding positions in the DNA-encoded key matrix to obtain an XOR result; Use the index array to scramble the XOR result to obtain a scrambled XOR result. Convert the scrambled XOR result into a DNA-encoded result according to the DNA dictionary, and determine the DNA-encoded result as the encrypted video data.
[0058] Among them, using the index array to scramble the XOR result to obtain the scrambled XOR result includes: flattening the XOR result into a one-dimensional array; rearranging each element in the one-dimensional array in the order of the index array to obtain the scrambled XOR result.
[0059] Optionally, a chaotic sequence can be generated in the following way: create a time array containing the total number of equally spaced points from 0 to the maximum number of time points. Call the odeint method to solve the Lorenz system. By transposing the array containing the solution, the solution array can be decomposed into three separate arrays: x, y, z. Crop x, y, z to retain only the first total number of time point values, which are the solutions of the Lorenz system in the x, y, z directions at each time point. Create a zero matrix of the same size as the chaotic sequence, sort the original chaotic sequence, loop through each element of the array, obtain the value of the current element, and call the bsearch function to perform a binary search in the sorted array to find the index of the element. The index represents the new position of the original chaotic sequence element in the sorted sequence.
[0060] It should be noted that the odeint method is a function in Python for numerically solving ordinary differential equations; the bsearch function is the binary search function for finding a specified element in an ordered array. If the return value is less than 0, it means the element to be searched is less than the elements in the ordered array; if the return value is greater than 0, it means the element to be searched is greater than the elements in the ordered array; if the return value is 0, it means the element to be searched has been found.
[0061] After encrypting the original video data, the method further includes: decrypting the encrypted video data, including: decoding the encrypted video data to obtain the decoded color values corresponding to each color channel; storing the two elements corresponding to the decoded color values in adjacent positions in the decoded binary array; packing the decoded binary array along the column direction to obtain a packed array, where each element in the packed array represents the color channel value of a pixel point; generating a decrypted image based on the packed array.
[0062] It can be understood that the decryption process is the reverse of the encryption process. The specific process is as follows: Decode each color channel of the image frame and pack the decoded values into a new array. Pair up the elements in these two tuples and assign color (the current color channel array) and dec (the corresponding decoded array) to the loop variables respectively in each iteration. Traverse each row and column of the input array (as well as the decoded array), obtain the element value of the current color channel array at the position (j, i) (i.e., the color value of a certain pixel) through color[j, i], convert this value to a string, and use the obtained string as a key to look up the corresponding value in the DNA dictionary. This value should be a tuple or list of length 2, representing two decoded bits. Finally, it assigns the first element (the element with index 0) of this tuple to the element of the decoded array at the position (j, 2 * i). Since the number of columns of the decoded array is twice that of the original array, 2 * i is used to calculate the column index. Assign the second element (the element with index 1) of the tuple found in the dna dictionary to the element of the decoded array at the position (j, 2 * i + 1). In this way, a color value in the original array is decoded into two bits and stored in two adjacent positions in the decoded array. Use the np.packbits function to pack each decoded channel array along the last axis (i.e., the column direction) into a more compact form. Since each color value may be represented by two bits after decoding, they are combined into consecutive bits in a byte.
[0063] The specific decoding process is as follows: At the beginning of decryption, a decoded two-dimensional array is initialized for each color channel (red, green, blue), with the same size as the color channel array before encryption, but with twice the number of columns, because each DNA base will generate two binary bits during decoding. Decode the DNA sequence: Read the DNA sequence of each color component from the encrypted image, and then traverse each row and column of these sequences. For each position (j, i), you read the DNA base value from the color array and use it as a key to look up the corresponding binary string in the DNA dictionary. This string is converted into a tuple that contains two binary bits. Store the decoded binary bits: Store the first bit (index 0) in the decoded tuple at position (j, 2i) in the decoded array, and the second bit (index 1) at position (j, 2i + 1). The reason for this is that the number of columns in the decoded array is twice that of the original array to ensure that the two bits of each DNA base are correctly separated and stored. Flatten the decoded array: Flatten the decoded array into a one-dimensional array for easy processing using the np.packbits function. Pack the binary bits: Use the np.packbits function in the numpy library to pack the decoded binary bit array along the last axis (i.e., the column direction). Since each color value after decoding is represented by two binary bits, these bits can be combined into a complete 8-bit byte value through the packing operation, thus restoring the original RGB value of the pixel. Restore the pixel values: After packing, you will get a flattened array where each element represents the restored 8-bit RGB value. Next, you need to reshape this flattened array into the shape of the original RGB image. Synthesize the RGB image: When you have obtained the decoded arrays for the red, green, and blue channels respectively, you need to synthesize them into an RGB image. This step is usually completed by recombining the three decoded arrays according to the color channels to form a three-dimensional array. Once the RGB image is synthesized, you can save it as a new image file to complete the decryption process.
[0064] Figure 3 Another video data encryption method is shown, such as Figure 3 shown, obtain image data, generate a key according to the image data, perform DNA encoding on the image data and the key, and update the chaotic system parameters according to the key to generate a chaotic sequence, and finally complete the encryption of the image data.
[0065] Figure 4 A video data encryption device according to an embodiment of the present application, the device includes:
[0066] An acquisition module 40, configured to acquire the original video data to be encrypted, and split the original video data to be encrypted frame by frame to obtain multiple frames of image data;
[0067] The first generation module 42 is configured to generate a plurality of keys based on the multi-frame images and generate a chaotic sequence based on the keys;
[0068] The encoding module 44 is configured to perform DNA encoding on the plurality of keys and the multi-frame images respectively to obtain a plurality of DNA-encoded key matrices and DNA encoding sequences;
[0069] The second generation module 46 is configured to generate encrypted video data based on the chaotic sequence, the DNA-encoded key matrix, and the DNA encoding sequence.
[0070] Through the above video data encryption device, by obtaining the original video data to be encrypted and splitting the original video data to be encrypted frame by frame to obtain multi-frame image data; generating a plurality of keys based on the multi-frame images and generating a chaotic sequence based on the keys; performing DNA encoding on the plurality of keys and the multi-frame images respectively to obtain a plurality of DNA-encoded key matrices and DNA encoding sequences; generating encrypted video data based on the chaotic sequence, the DNA-encoded key matrix, and the DNA encoding sequence, thereby achieving the purpose of jointly generating encrypted video data based on the chaotic sequence, DNA encoding, and keys, thus realizing the technical effect of improving the security of video data, and further solving the technical problem of low security of image data in a private cloud in the related art.
[0071] The encoding module 44 includes: an encoding sub-module configured to perform DNA encoding on the multi-frame images to obtain a DNA encoding sequence, including: respectively obtaining the RGB values of all pixel points in each frame of the image and converting the RGB values of all pixel points into a binary format; converting the RGB values in the binary format of each pixel point into a DNA encoding sequence according to a preset DNA dictionary, where the preset DNA dictionary includes the mapping relationship between binary encodings and multiple bases of DNA.
[0072] The encoding sub-module includes an encoding unit configured to convert the RGB values in the binary format of each pixel point into a DNA encoding sequence according to a preset DNA dictionary, including: splitting the RGB values in the binary format of each pixel point into a plurality of binary encodings; respectively converting the plurality of binary encodings according to the DNA dictionary to obtain the DNA encoding sequence.
[0073] The encoding module 44 includes a matrix sub-module for performing DNA encoding on the multiple keys to obtain multiple DNA-encoded key matrices, including: converting the RGB value of each pixel into byte data, and using a hash algorithm to convert the byte data into a hash value; converting the hash value into a hexadecimal string to obtain a key; converting the key into an integer, and then converting the integer into a binary string, where the length of the binary string is 256 bits; filling the binary string of each pixel into an initial matrix to obtain the key matrix, and the shape of the initial matrix is the same as the shape of the color channel array of the multiple frames of images; splicing the first element of the current row in the key matrix and the second element adjacent to the first element into a target string; obtaining the DNA base value corresponding to the target string in a preset dictionary, and storing the DNA base value corresponding to the target string in the preset dictionary in the specified column of the current row of the DNA-encoded key matrix.
[0074] The matrix sub-module includes: a chaotic sequence unit for generating a chaotic sequence according to the key, including: splitting the binary string corresponding to the key into multiple segments of a fixed length; dividing the multiple segments into three parts, where exclusive OR operations are respectively performed on the segments of each part to obtain three exclusive OR operation results; respectively converting the three exclusive OR operations into three floating-point numbers, and respectively using the three floating-point data to update the parameters of the chaotic system; generating the chaotic sequence using the chaotic system with updated parameters, and each element in the chaotic sequence is used to represent the solutions of the chaotic system in the X-axis, Y-axis, and Z-axis directions at each time point.
[0075] The second generation module 46 includes: an encryption sub-module for generating encrypted video data according to the chaotic sequence, the DNA-encoded key matrix, and the DNA encoding sequence, including: using a sorting function to sort each element in the chaotic sequence, and generating an index array according to the sorted chaotic sequence, where the index array is used to represent the position of each element in the sorted chaotic sequence; performing an exclusive OR operation on each element at each position in the DNA encoding sequence corresponding to each color channel and the element at the corresponding position in the DNA-encoded key matrix to obtain an exclusive OR result; using the index array to scramble the exclusive OR result to obtain a scrambled exclusive OR result. Converting the scrambled exclusive OR result into a DNA encoding result according to the DNA dictionary, and determining the DNA encoding result as the encrypted video data.
[0076] The encryption sub-module includes: an encryption unit, which is used to scramble the XOR result by using the index array to obtain the scrambled XOR result, including: flattening the XOR result into a one-dimensional array; rearranging each element in the one-dimensional array in the order of the index array to obtain the scrambled XOR result.
[0077] The encryption unit contains an encryption sub-unit, which is used to decode the encrypted video data to obtain the decoded color values corresponding to each color channel; store two elements corresponding to the decoded color values at adjacent positions in the decoded binary array; pack the decoded binary array in the column direction to obtain a packed array, and each element in the packed array represents the color channel value of a pixel point; generate a decrypted image according to the packed array.
[0078] It should be noted that Figure 4 the shown video data encryption device is used to execute Figure 2 the shown video data encryption method. Therefore, the relevant explanations in the above video data encryption method also apply to this video data encryption device, and will not be elaborated here.
[0079] An embodiment of the present application further provides a computer device, including: a memory and a processor. Among them, the memory is used to store program instructions; the processor is connected to the memory and is used to execute the above video data encryption method.
[0080] An embodiment of the present application further provides a non-volatile storage medium, which includes a stored computer program. Among them, the device where the non-volatile storage medium is located executes the above video data encryption method by running the computer program.
[0081] An embodiment of the present application further provides a computer program product, including computer instructions, and when the computer instructions are executed by a processor, the steps of the video data encryption method in the present application are implemented.
[0082] The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.
[0083] In the above embodiments of the present application, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0084] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings or direct couplings or communication connections shown or discussed with each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.
[0085] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0086] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0087] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: various media such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs that can store program codes.
[0088] The above is only the preferred embodiment of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. A video data encryption method, characterized in that: include: Acquire original video data to be encrypted, and split the original video data to be encrypted frame by frame to obtain multiple frames of image data; Generate multiple keys according to the multiple frame images, and generate a chaotic sequence according to the keys; Performing DNA encoding on the multiple keys and the multiple frames of images respectively to obtain multiple DNA-encoded key matrices and DNA encoding sequences; Encrypted video data is generated according to the chaotic sequence, the DNA-encoded key matrix and the DNA encoding sequence.
2. The method according to claim 1, characterized in that Performing DNA encoding on the multiple frames of images to obtain a DNA encoding sequence includes: Get the RGB values of all pixels in each frame of the image respectively, and convert the RGB values of all pixels into binary format; The RGB value of each pixel in binary format is converted into a DNA coding sequence according to a preset DNA dictionary, wherein the preset DNA dictionary contains a mapping relationship between the binary code and multiple bases of DNA.
3. The method according to claim 2, characterized in that The binary RGB value of each pixel is converted into a DNA coding sequence according to the preset DNA dictionary, including: Split the binary RGB value of each pixel into multiple binary codes; The multiple binary codes are converted respectively according to the DNA dictionary to obtain the DNA coding sequence.
4. The method according to claim 1, characterized in that: DNA encoding is performed on the multiple keys to obtain multiple DNA-encoded key matrices, including: Convert the RGB value of each pixel into byte data, and convert the byte data into a hash value using a hash algorithm; Convert the hash value into a hexadecimal string to obtain a key; Convert the key into an integer, and then convert the integer into a binary string, wherein the length of the binary string is 256 bits; Filling the binary string of each pixel into the initial matrix to obtain the key matrix, wherein the shape of the initial matrix is the same as the shape of the color channel array of the multi-frame image; Concatenate the first element of the current row in the key matrix and the second element adjacent to the first element into a target string; The DNA base value corresponding to the target character string in the preset dictionary is obtained, and the DNA base value corresponding to the target character string in the preset dictionary is stored in a specified column of the current row of the key matrix after the DNA encoding.
5. The method according to claim 4, characterized in that Generating a chaotic sequence according to the key includes: Splitting the binary string corresponding to the key into multiple segments of fixed length; Dividing the multiple fragments into three parts, wherein performing an XOR operation on the fragments of each part respectively to obtain three XOR operation results; Converting the three XOR operations into three floating point numbers respectively, and using the three floating point data to update the parameters of the chaotic system respectively; The chaotic sequence is generated by using the chaotic system with updated parameters, and each element in the chaotic sequence is used to represent the solution of the chaotic system in the directions of the X-axis, the Y-axis and the Z-axis at each time point.
6. The method according to claim 2, characterized in that Generating encrypted video data according to the chaotic sequence, the key matrix after the DNA encoding, and the DNA encoding sequence, comprising: Using a sorting function to sort each element in the chaotic sequence, and generating an index array according to the sorted chaotic sequence, wherein the index array is used to represent the position of each element in the sorted chaotic sequence; Performing an XOR operation on the element at each position in the DNA coding sequence corresponding to each color channel and the element at the corresponding position in the key matrix after DNA coding to obtain an XOR result; Using the index array to disturb the XOR result to obtain a disturbed XOR result; The disturbed XOR result is converted into a DNA encoding result according to the DNA dictionary, and the DNA encoding result is determined as the encrypted video data.
7. The method according to claim 6, characterized in that The XOR result is disturbed by using the index array to obtain a disturbed XOR result, including: Flatten the XOR result into a one-dimensional array; Each element in the one-dimensional array is rearranged according to the order of the index array to obtain the disturbed XOR result.
8. The method according to claim 7, characterized in that The method further comprises: Decoding the encrypted video data to obtain a decoded color value corresponding to each color channel; storing two elements corresponding to the decoded color value in adjacent positions in the decoded binary array; Packing the decoded binary array along the column direction to obtain a packed array, each element in the packed array represents a color channel value of a pixel; A decrypted image is generated according to the packed array.
9. A video data encryption device, characterized in that: include: An acquisition module is used to acquire original video data to be encrypted, and split the original video data to be encrypted frame by frame to obtain multiple frames of image data; A first generating module, used for generating a plurality of keys according to the plurality of frames of images, and generating a chaotic sequence according to the keys; An encoding module, used for performing DNA encoding on the multiple keys and the multiple frames of images respectively, to obtain multiple DNA-encoded key matrices and DNA encoding sequences; The second generating module is used to generate encrypted video data according to the chaotic sequence, the key matrix after the DNA encoding and the DNA encoding sequence.
10. A computer device, characterized in that: include: A memory and a processor, wherein the memory is used to store program instructions; The processor is connected to the memory and is used to execute the video data encryption method described in any one of claims 1 to 7.
11. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the video data encryption method described in any one of claims 1 to 8 is implemented.