A method and system for encrypting, storing and decrypting pictures and videos
By fragmenting picture or video data and combining AES and RSA encryption algorithms, the problems of insufficient encryption strength and slow decryption speed in the existing technology are solved, efficient and secure data transmission and storage are achieved, and the integrity and integrity of the data are enhanced. Privacy protection.
Patent Information
- Application Number
- CN202410751260.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-06-12
AI Technical Summary
The existing technology has insufficient encryption strength, slow decryption speed, and high key management risks during the transmission of pictures and videos, making it difficult for data security and privacy protection to meet high-demand data storage needs such as electronic photo albums.
Adopt a shard encryption method based on device performance to divide picture or video data into shards with different storage capacities, use the AES encryption algorithm to encrypt each shard, and use the RSA encryption algorithm to encrypt the encrypted shards. Communication encryption, generating key matrix and deordering index, achieving efficient management of shard keys and double encryption protection of data.
It improves the flexibility and efficiency of encryption, significantly improves data security and integrity, reduces the risk of data loss, prevents illegal access through dynamic key management and session identification timeliness, and ensures data transmission and storage. security in.
Smart Images

Figure CN118338048B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic data processing and transmission, and in particular to the field of picture and video transmission. Background Art
[0002] With the widespread application of cloud computing technology, cloud storage services have gradually become the first choice for personal and corporate data storage. However, the data security and privacy issues that come with it have also attracted much attention. There are currently a variety of data encryption technologies on the market, but they all have more or less problems such as insufficient encryption strength, slow decryption speed, or key management risks.
[0003] In the field of electronic photo albums, the requirements for data transmission and storage are relatively high, because a large part of them are used in family albums, and the data includes the user's personal privacy issues. In the process of picture and video transmission, the security of encryption and the speed of decryption have become the technical points of focus in the industry.
[0004] The invention patent application publication number CN115988241A discloses a data transmission method for uploading short videos in segments, including the following steps: S1, data segment cutting: segment and transcode the data segments to be uploaded, and then perform data entry operation; S2, data classification: mark the transcoded data after segmentation and entry, sort the data packets of the entered data resources through a sorting algorithm, and then generate a serial number mark for preservation; S3, data audit preview: locate the data segment according to the serial number mark generated by the sorting algorithm, arrange and combine according to the serial number mark, and perform data inspection on the data through a code preview unit, and mark the messy data in the data segment; S4, data review: mark the messy data in the data segment The data is checked and verified. After the review, the new data segment is transcoded by the transcoding unit and then transmitted to the image source device through the transmission channel. The image source device plays the data segment in segments to verify the integrity of the data; S5, data segment integration: the data segments are integrated according to the sequence of serial number markings, the data segments are named according to the sequence of serial number markings, and the sorting order of the data segments in the sorting algorithm is integrated as the video playback order; S6, data upload: the integrated data video is sent to the video playback unit through the sending unit, and the video playback unit performs a pre-playback to check the integrity and smoothness of the playback data. The segmented data source after the S4 data review in the final approved video resource is the final data resource of the short video. S7, data encryption: the data segment of the data review in S4 is encrypted through the encryption function to encrypt the segmented data segment, the data code of the single data segment is encrypted, and the data segment name after the serial number mark is hidden with *, the encrypted data segment is the final uploaded data material, and the data segment is stored in the terminal memory. During the entire process, from data slicing to encryption and uploading, classification and review rehearsal operations will be required first. This requires the intermediate processing process to verify integrity before uploading. This series of operations will make the pre-encryption operations too complicated, and encryption is not efficient. Verifying integrity through fragmented playback of image source devices itself makes the processing process too cumbersome. Summary of the invention
[0005] In the first aspect, the purpose of this application is to overcome the above technical problems and provide a method for encrypting, storing and decrypting pictures and videos, comprising the following steps:
[0006] Based on the current device performance parameters, the image or video data information is divided into slices of different storage capacity sizes to obtain a slice set;
[0007] Parse and AES encrypt each shard data in the shard set, obtain shard metadata through parsing, obtain encrypted shard data and shard key through AES encryption, and generate a shard index based on the shard metadata;
[0008] Generate a first encrypted file based on the encrypted shard data and the shard metadata combination;
[0009] Using the RSA encryption algorithm to encrypt the first encrypted files, generating the second encrypted files accordingly, and uploading the sharding key and the second encrypted files to the server;
[0010] Based on the number of the shard keys, a key matrix is generated, the shard keys are filled into the key matrix, and a de-sequence index is generated;
[0011] When the terminal and the server conduct an acquisition session, a read matrix is generated and a key matrix is acquired. The read matrix performs a de-sequencing process on the key matrix based on the de-sequencing index to acquire the second encrypted file and the sharding key;
[0012] The second encrypted file is subjected to RSA decryption processing to obtain the first encrypted file, the first encrypted file is decrypted based on the sharding key and the sharding metadata, and a complete picture or video file is reassembled and transmitted back to the terminal.
[0013] By adopting the above technical solution, the image or video data information is fragmented, and each fragment is encrypted using the AES encryption algorithm. The AES encryption algorithm is a widely used symmetric encryption algorithm that enhances the security of the data. During the data transmission process, the RSA encryption algorithm is used to encrypt the communication of the first encrypted file. The RSA encryption algorithm is an asymmetric encryption algorithm suitable for data encryption and digital signatures. It can ensure that the data is not tampered with or stolen during the transmission process, and further ensure the security of the data during the transmission process. The fragmentation mechanism allows some fragments to be lost or damaged during the transmission process, and can also be restored through other fragmentation indexes, which not only improves the security of data storage, but also ensures the integrity and recoverability of the data, and reduces the risk of data loss. By generating a key matrix and a de-sequenced index, efficient management of the fragmentation key is achieved. This management method not only ensures the security of the key, but also facilitates rapid key search and use when needed.
[0014] Preferably, the step of parsing and AES encrypting each shard data further includes: a key used for AES encryption of each shard data is generated based on the shard metadata.
[0015] By adopting the above technical solution, the shard metadata contains information about the importance, sensitivity or other security-related information of the shard. The keys generated based on this information can ensure that different security encryption levels are applied to different shards. When data needs to be re-sharded or some shards need to be replaced, only the relevant shard metadata needs to be updated and new keys need to be generated based on the new metadata without making large-scale modifications to the entire encryption system.
[0016] Preferably, the slice metadata includes file format, timestamp information, and slice sequence.
[0017] By adopting the above technical solution, the file format information allows the receiver to verify whether the format of the data is correct after decrypting the fragments, ensuring that the data has not been tampered with during transmission. The timestamp information can ensure the timeliness of the data and is used to verify the latest status of the data to prevent the use of outdated data. The fragment sequence information can help the receiver reassemble the data in the correct order after obtaining all the fragments to ensure the integrity and availability of the data. The fragment sequence and timestamp information can also verify each other to ensure that the data has not been tampered with, thereby improving data security.
[0018] Preferably, in the step of combining to generate the first encrypted file, the order of the combinations is consistent with the shard index.
[0019] By adopting the above technical solution, when the receiver receives the encrypted shards and tries to reassemble, if the order of combination is inconsistent with the shard index, the reassembled data may be erroneous or damaged. By keeping the combination order consistent with the shard index, the integrity and accuracy of the data can be ensured, so that the receiver can correctly decrypt and restore the original data. In addition, when the shards are combined in index order, if a shard is lost or damaged during transmission, the receiver can more easily identify this problem and request to resend the lost shard. This mechanism enhances the security of the data because any incomplete shard will not be mistakenly used to reassemble the data.
[0020] Preferably, the step of generating the key matrix further includes: the de-sequenced index is generated based on the coordinates of the key matrix filled with the shard key, and the de-sequenced index is a bidirectional index.
[0021] By adopting the above technical solution, since the de-sequencing index is generated based on the coordinates of the key matrix and is closely related to the shard key, it increases the difficulty for attackers to crack the key. The attacker not only needs to know the structure of the key matrix, but also needs to understand the correspondence between the shard key and the de-sequencing index in order to carry out an effective attack. During the data recovery process, if a shard key is lost or damaged, the position of the key in the key matrix can be quickly located through the de-sequencing index, so that corresponding recovery measures can be taken, which can reduce the time and cost of data recovery.
[0022] Preferably, the step of generating the reading matrix also includes: when requesting a session with the server, the server returns a session identifier and generates a session identifier key for interactive matching, the session identifier is encrypted data, the session identifier key is randomly generated by the server, and the session identifier is time-sensitive.
[0023] By adopting the above technical solution, the session identifier has a time limit. Once the set time limit is exceeded, the session identifier will become invalid. This can prevent attackers from using intercepted session identifiers to hijack sessions, because expired session identifiers cannot be accepted by the server. When the client uses a valid session identifier to interact with the server, the server can ensure that the data is sent from a legitimate client and that the data has not been tampered with during transmission. This helps to achieve secure data transmission and interaction. If a session identifier is leaked or expires, the server can simply change or delete the session identifier to reduce system risks. At the same time, since the session identifier has a time limit, even if it is leaked, it will not have a long-term impact on the system.
[0024] Preferably, the step of de-sequencing the key matrix by the reading matrix further includes: the reading matrix is formed by irregular mapping of the key matrix and has a time limit, and when the interaction with the server exceeds a preset time, the key matrix will modify the mapping address.
[0025] By adopting the above technical solution, the time-limited design means that the mapping relationship will change regularly. Even if an attacker cracks the mapping relationship at a certain point in time, this relationship will become invalid over time, thereby continuously ensuring the security of the data. For attackers who try to obtain keys through brute force or other illegal means, irregular mapping makes access to the key matrix complicated and unpredictable, which greatly increases the difficulty of illegal access. Attackers cannot simply obtain the correct mapping relationship through guessing or analysis.
[0026] Preferably, the step of de-sequencing the key matrix by the reading matrix further includes: when the session identifier changes, the key matrix modifies the mapping address.
[0027] By adopting the above technical solution, in actual applications, the modification of the key matrix mapping address triggered by the change of the session identifier can ensure that even if the session identifier is stolen, the attacker cannot use it to access the key matrix for a long time because the mapping address has changed. This dynamicity increases the difficulty of cracking by the attacker, thereby improving the security of the session.
[0028] Preferably, the step of dividing into slices with different storage capacity sizes also includes: when the average time it takes for the server to send data is greater than the preset transmission time, the number of slices into which the picture or video data is divided is reduced; when the average time it takes for the server to send data is less than the preset transmission time, the number of slices into which the picture or video data is divided is increased.
[0029] By adopting the above technical solution, when the average time for the server to send data is greater than the preset transmission time, it means that the data transmission speed is slow or the network conditions are not good. At this time, reducing the number of fragments of the image or video data can reduce the number of data packets and transmission time during the transmission process, thereby reducing transmission delays and improving user experience. On the contrary, when the average time for the server to send data is less than the preset transmission time, it means that the network conditions are good. At this time, increasing the number of fragments of the image or video data can achieve more fine-grained data transmission and control while ensuring transmission efficiency, further improving user experience.
[0030] In summary, the present invention has at least the following beneficial effects:
[0031] The present invention adopts a picture and video fragment encryption method based on device performance, which improves the flexibility and efficiency of encryption and reduces the resource consumption of encryption and decryption processes by dividing the file into multiple fragments for encryption processing.
[0032] The present invention preferably adopts an encryption method combining AES and RSA. By first performing AES encryption on the slices and then performing RSA communication encryption on the encrypted slices, double encryption protection is achieved, thereby significantly improving the security of data storage and transmission.
[0033] By generating a key matrix and a decryption index, the present invention can flexibly manage and control the decryption order of the slices, increase the complexity and difficulty of data decryption, and further ensure the security of the data.
[0034] The introduction of the read matrix in the present invention causes the key matrix mapping address to change in each session. Even if the session identifier or interaction time exceeds a preset limit, the key matrix will modify the mapping address, thereby effectively preventing malicious attacks and illegal access. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1This is a first flow chart of a method for encrypting, storing and decrypting pictures and videos according to an embodiment of the present application;
[0036] Figure 2 This is a flowchart of step S20 of a method for encrypting, storing and decrypting pictures and videos according to an embodiment of the present application;
[0037] Figure 3 This is a flowchart of step S60 of a method for encrypting, storing and decrypting pictures and videos according to an embodiment of the present application;
[0038] Figure 4 This is a flowchart of step S10 of a method for encrypting, storing and decrypting pictures and videos in one embodiment of the present application;
[0039] Figure 5 This is a system module diagram of a picture and video encryption storage and decryption system according to an embodiment of the present application;
[0040] In the figure, 10, data segmentation module; 20, shard parsing and encryption module; 30, shard metadata combination module; 40, communication encryption module; 50, key de-sequencing generation module; 60, reading matrix generation module; 70, shard de-sequencing combination module. DETAILED DESCRIPTION
[0041] The following is combined with Figure 1 -Attached Figure 5 , further details of this application are given.
[0042] In one embodiment, referring to Figure 1 , a method for encrypting, storing and decrypting pictures and videos, comprising the following steps:
[0043] S10. Based on current device performance parameters, the image or video data information is divided into slices of different storage capacity sizes to obtain a slice set.
[0044] Combine the performance parameters of the current device, such as storage capacity, network bandwidth, and processing power, to dynamically adjust the image or video data segmentation strategy. For example, when the device has good storage capacity, network, and processing power, an appropriate slicing algorithm can be used to segment the image or video data stream into data stream segments with smaller preset data files to form a segment set, because a smaller preset data file is equivalent to a larger number of data stream segments, and subsequent parsing, encryption, and other behaviors will increase the size of the data stream. On the contrary, if the device has poor storage capacity, network, and processing power, the image or video data stream is segmented into data stream segments with larger preset data files to ensure that subsequent segments can have a better transmission experience after being encrypted.
[0045] S20. Parse and AES encrypt each shard data in the shard set, obtain shard metadata through parsing, obtain encrypted shard data and shard key through AES encryption, and generate a shard index based on the shard metadata.
[0046] Parse the data stream of each shard in the shard set and extract the shard metadata. These metadata include but are not limited to the size of the shard, data format, and location information in the original image or video. During the AES encryption process, a unique shard key is generated for each shard. This key will be used for subsequent decryption operations to ensure the confidentiality and integrity of the data. Based on the parsed shard metadata, a shard index is generated, which records the location and related information of each shard in the original image or video. The shard index is crucial for subsequent file reorganization, as it ensures that the encrypted shard data can be reassembled into a complete image or video file in the correct order and position.
[0047] S30: Generate a first encrypted file based on the encrypted shard data and shard metadata.
[0048] The encrypted shard data generated in step S20 is integrated with the corresponding shard metadata (such as shard size, encryption method, shard sequence number, etc.), and a new file format or data structure is created based on the integrated data. This format can accommodate the encrypted shard data and shard metadata and ensure their relevance. This is done to facilitate subsequent file management, transmission and storage.
[0049] S40, using the RSA encryption algorithm to encrypt the communication of several first encrypted files, generating several second encrypted files accordingly, and uploading the sharding key and the second encrypted files to the server.
[0050] Generate an RSA public key and private key pair, the public key is used for encryption, and the private key is used for decryption. Select the first encrypted file previously encrypted and generated by AES, and use the RSA public key to encrypt each first encrypted file, so as to provide additional security during the file transfer process, ensuring that even if the data is intercepted during transmission, it cannot be easily decrypted. The encrypted file is called the second encrypted file. In this step, the shard data is in a double-layer encryption state: one layer is AES shard encryption, and the second layer is RSA communication encryption. Finally, pair each second encrypted file with the corresponding shard key and upload it to the server.
[0051] S50: Generate a key matrix based on the number of shard keys, fill the shard keys into the key matrix, and generate a de-sequence index.
[0052] First, the total number of shard keys needs to be determined. Based on the number of shard keys, the size and structure of the key matrix should be determined. The key matrix should be able to accommodate all shard keys. Each shard key is randomly filled into the key matrix according to the predetermined filling algorithm. In order to correctly reorganize the key when needed, a de-sequence index is generated while filling. For example, if the number of shard keys is 9, a 3x3 key matrix is generated, and then the shard keys are randomly filled into the key matrix through the preset filling algorithm, and a de-sequence index is generated when each shard key is filled.
[0053] S60: When the terminal and the server are acquiring a session, a read matrix is generated and a key matrix is acquired. The read matrix de-sequences the key matrix based on the de-sequence index to acquire the second encrypted file and the sharding key.
[0054] When the terminal establishes a session with the server, a read matrix is first generated. The terminal obtains the key matrix from the server through a secure channel. The key matrix has been randomly filled on the server side according to the number and rules of the sharding keys. The terminal also obtains the de-sequencing index corresponding to the key matrix. Using this de-sequencing index, the terminal de-sequencing the key matrix. Through de-sequencing, the terminal can extract the second encrypted file that was previously sharded and encrypted and stored. Using the de-sequencing index for de-sequencing and other technical means, the secure acquisition and decryption of the sharded encrypted files are realized, which improves the security of data storage and transmission.
[0055] S70, performing RSA decryption processing on the second encrypted file to obtain the first encrypted file, decrypting the first encrypted file based on the sharding key and the sharding metadata, recombining the complete picture or video file and transmitting it back to the terminal.
[0056] The second encrypted file is decrypted using the RSA algorithm, and after RSA decryption, the first encrypted file is obtained. This file was previously encrypted, but the encryption method was not RSA, but the first encrypted file encrypted based on the shard key and shard metadata, and then the first encrypted file is decrypted using the corresponding shard key and shard metadata. Among them, the shard key may be a complete key divided into multiple partial shards, each part is used to decrypt a part of the file. The shard metadata may contain information about how to reassemble these shards. According to the shard sequence in the shard metadata, the decrypted shards are reassembled into a complete file.
[0057] The implementation principle of the embodiment of the present application is: combining data slicing, double encryption, key management and data reorganization technology to ensure the security and integrity of data during transmission and storage. Through data slicing, the original picture or video data is divided into slices of different sizes to adapt to the performance of the device and improve the flexibility of data processing. The double encryption mechanism protects the content of the data slices through AES encryption, and then uses RSA encryption to enhance the security of data transmission. Key management realizes efficient management and accurate extraction of slice keys through key matrix and de-sequence index. Finally, in the data reorganization stage, the decrypted slices are reassembled into complete files using slice indexes and metadata. This solution can significantly improve the security of data. Even if the data is intercepted during transmission, it is difficult for attackers to decrypt and obtain the original content. In addition, through double encryption and precise data reorganization technology, the solution ensures the integrity and authenticity of the data, and effectively prevents the data from being tampered with or damaged during transmission. In summary, this solution protects the user's sensitive data in an efficient, safe and flexible manner, and provides users with reliable data security protection.
[0058] In a specific embodiment, based on the specific steps in step S20, refer to Figure 2 Also includes:
[0059] S201. The key used for AES encryption of each shard data is generated based on the shard metadata.
[0060] For each shard data, instead of using a unified key for encryption, an AES key is generated based on the metadata of the shard. Using a preset hash function, the shard metadata is used as input and a fixed-length key is output. This key is then used to encrypt the shard with AES. This method allows different keys to be used for different shards, which provides greater flexibility. For example, if the data of a shard is particularly sensitive, a more complex key can be generated for the shard by adjusting the metadata or key generation algorithm.
[0061] In a specific embodiment, the fragment metadata in step S20 includes file format, timestamp information, and fragment sequence.
[0062] By recording the file format, timestamp, and shard sequence, the integrity and accuracy of the data can be ensured. During the decryption and reassembly phases, these metadata will be used to verify the identity and location of each shard, thereby ensuring the correct recovery of the data. If an error occurs during transmission or storage, resulting in the loss or damage of some shards, by comparing the timestamp and shard sequence, the problem can be quickly located and appropriate recovery measures can be taken.
[0063] In a specific embodiment, the order of the combination of encrypted shard data and shard metadata in step S30 is consistent with the shard index.
[0064] By maintaining the consistency of encrypted shard data, shard metadata, and shard index, the integrity of data can be ensured during transmission or storage. Even if part of the shard is lost or damaged during transmission, the receiver can identify the missing or damaged part based on the shard index and metadata information. If either the shard metadata or the shard index is damaged, there will be another identifier to act on the subsequent decryption and reorganization to ensure stability.
[0065] In a specific embodiment, the de-sequenced index generated in step S50 is generated based on the coordinates of the key matrix filled with the shard key, and the de-sequenced index is a bidirectional index.
[0066] When the shard key is filled into a specific position in the key matrix, the system records the coordinates (rows and columns) corresponding to each shard key. This coordinate is the unique position identifier of the shard key in the key matrix. The bidirectional index includes a forward index and a reverse index. The forward index has a key that is the identifier or value of the shard key, and a value that is the coordinate of the shard key in the key matrix. In this way, the shard key can be quickly found in the key matrix. The reverse index has a key that is the coordinate in the key matrix, and a value that is the shard key corresponding to the coordinate. In this way, the corresponding shard key can be quickly retrieved through the coordinate in the key matrix. The two indexes can be associated to form a bidirectional index. Through this process, the de-sequenced index realizes a bidirectional fast mapping between the shard key and its coordinate in the key matrix, thereby improving the efficiency and accuracy of key retrieval during encryption and decryption.
[0067] In a specific embodiment, referring to Figure 3 After the terminal acquires the session with the server in step S60, the following steps are specifically included:
[0068] S601. When requesting a session with a server, the server returns a session identifier and generates a session identifier key for interactive matching. The session identifier is encrypted data. The session identifier key is randomly generated by the server. The session identifier is time-limited.
[0069] After receiving the session request, the server first performs identity authentication and security checks. After the verification is passed, the server will generate a unique session identifier, which is usually generated by a secure encryption algorithm such as RSA to ensure its uniqueness and security. While generating the session identifier, the server will also randomly generate a session identifier key. This key is used to verify the session identifier in the subsequent communication process to prevent tampering or object changes during the communication process. The server returns the session identifier and session identifier key to the terminal. After receiving this information, the terminal will use the session identifier key to encrypt the data and then send it to the server for verification. The server uses the same session identifier key to decrypt the data to confirm that both parties have successfully established a secure communication channel. The session identifier is time-sensitive, that is, it will automatically expire after a period of time to increase the security of the system. The server will maintain a list of session identifier validity periods and regularly check and clear expired session identifiers. When the terminal attempts to communicate using an expired session identifier, the server will reject the request and require the terminal to re-authenticate and re-establish the session.
[0070] In a specific embodiment, referring to Figure 3 In step S60, a read matrix is generated, and a key matrix is obtained. The read matrix performs de-sequencing on the key matrix based on the de-sequencing index, and the step of obtaining the second encrypted file and the sharding key specifically includes the following steps:
[0071] S602, the reading matrix is formed by irregular mapping of the key matrix and has a time limit. When the interaction with the server exceeds a preset time, the key matrix will modify the mapping address.
[0072] Generate an empty data matrix as the read matrix, and then fill the read matrix based on the key matrix irregular mapping algorithm. That is, the read matrix stores unordered keys, and the original keys cannot be directly obtained. When the client requests decryption or access to encrypted data, the server will provide a de-sequencing index. The client uses this de-sequencing index to de-sequence the read matrix. This process is to rearrange the elements in the read matrix according to the index to restore the correct correspondence with the key matrix. Through the de-sequenced read matrix, the client can correctly access the key information in the key matrix. This key information is then used to decrypt the second encrypted file or obtain the sharding key.
[0073] S603: When the session identifier changes, the key matrix set will modify the mapping address.
[0074] First, when the client establishes a session with the server, the server assigns a session identifier, which is unique and used to identify and track the session. Based on this session identifier, the server generates a key matrix. Next, the server generates a read matrix, which is associated with the key matrix through irregular mapping. At the same time, this mapping relationship is time-limited. When the interaction time with the server exceeds the preset limit, the server automatically updates or resets the mapping relationship to ensure security. During the session, if the session identifier changes, it may be triggered by session timeout, user re-login, or other security policies. The key matrix set will modify its mapping address and the old mapping relationship will become invalid. When the client needs to use the key, it will de-sequence the read matrix through the de-sequence index, but since the change of the session identifier causes the modification of the mapping address of the key matrix, the client must re-synchronize with the server to obtain the new mapping relationship. In this way, even if the attacker intercepts the read matrix and de-sequence index at a certain point in time, they cannot use this information for malicious behavior for a long time due to the change of the session identifier and the dynamic update of the mapping address.
[0075] In a specific embodiment, referring to Figure 4 In step S10, based on the current device performance parameters, the image or video data information is divided into slices of different storage capacity sizes to obtain a slice set, which specifically includes the following steps:
[0076] S101. When the average duration of the server sending data is greater than the preset transmission duration, the number of slices into which the image or video data is segmented is reduced; when the average duration of the server sending data is less than the preset transmission duration, the number of slices into which the image or video data is segmented is increased.
[0077] By recording the timestamp and data volume of each data transmission on the server side, the average data transmission time within a time period can be calculated. This average transmission time reflects the efficiency of the server in transmitting data to the client. The preset transmission time is a threshold set according to system requirements and network conditions, which is used to evaluate whether the current network transmission efficiency meets the standard. Compare the calculated average time with this preset value. If the average time for the server to send data is longer than the preset transmission time, it means that the current network transmission efficiency is low. In order to reduce the overhead and improve efficiency during the transmission process, the system will reduce the number of fragments of the image or video data. This means that the amount of data in each fragment will be relatively large, but the total number of fragments will be reduced, thereby reducing the transmission gap between fragments and the possible number of retransmissions. Conversely, if the average time for the server to send data is less than the preset transmission time, it means that the current network transmission efficiency is high. At this time, the system will increase the number of fragments of the image or video data to make more full use of the efficient network environment. Doing so can make each fragment be transmitted faster and increase the possibility of parallel processing.
[0078] The embodiment of the present application provides a method for encrypting, storing and decrypting pictures and videos. By real-time monitoring the average time it takes for a server to send data, the method dynamically adjusts the number of slices of picture or video data to optimize network transmission efficiency. At the same time, the method generates a read matrix using irregular mapping, and modifies the mapping address when a time limit and session identifier change to enhance the security of data encryption. Finally, the read matrix is de-sequenced through a de-sequenced index to obtain encrypted files and slice keys, thereby achieving secure storage and access to data.
[0079] In another embodiment, a system for encrypting, storing and decrypting pictures and videos is provided, which corresponds to the method for encrypting, storing and decrypting pictures and videos in the above embodiment. Figure 5 , the picture and video encryption storage and decryption system includes:
[0080] Data segmentation module 10: used to segment the image or video data information into slices of different storage capacity sizes based on current device performance parameters to obtain a slice set;
[0081] The shard parsing and encryption module 20 is used to parse and AES encrypt each shard data in the shard set, parse to obtain shard metadata, encrypt to obtain encrypted shard data and shard key by AES, and generate a shard index based on the shard metadata;
[0082] Slice metadata combination module 30: used to generate a first encrypted file based on the encrypted slice data and the slice metadata combination;
[0083] Communication encryption module 40: used to use RSA encryption algorithm to encrypt several first encrypted files, generate several second encrypted files accordingly, and upload the sharding key and the second encrypted files to the server;
[0084] The key de-sequencing generation module 50 is used to generate a key matrix based on the number of shard keys, fill the shard keys into the key matrix, and generate a de-sequencing index at the same time;
[0085] Reading matrix generation module 60: used to generate a reading matrix and obtain a key matrix when the terminal and the server are acquiring a session, wherein the reading matrix performs de-sequencing on the key matrix based on the de-sequencing index to obtain the second encrypted file and the sharding key;
[0086] The fragment de-sequencing and combining module 70 is used to perform RSA decryption processing on the second encrypted file to obtain the first encrypted file. The first encrypted file is decrypted based on the fragment key and the fragment metadata, and reassembled into a complete picture or video file and transmitted back to the terminal.
[0087] The implementation principle of a picture and video encryption storage and decryption system in this embodiment is basically the same as a picture and video encryption storage and decryption method. Please refer to the implementation principle mentioned above and will not be repeated here.
[0088] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A method for encrypting, storing and decrypting pictures or videos, characterized in that: The following steps are involved: Based on the server performance parameters, the image or video data information is divided into slices of different storage capacity sizes to obtain a slice set; Parse and AES encrypt each shard data in the shard set, obtain shard metadata through parsing, obtain encrypted shard data and shard key through AES encryption, and generate a shard index based on the shard metadata; Generate a first encrypted file based on the encrypted shard data and the shard metadata combination; Using the RSA encryption algorithm to encrypt the first encrypted files, generate a number of second encrypted files, and upload the sharding key and the second encrypted files to the server; Based on the number of the shard keys, a key matrix is generated, the shard keys are filled into the key matrix, and a de-sequence index is generated; When the terminal conducts an acquisition session with the server, the terminal generates an empty data matrix as a read matrix, fills the read matrix based on the key matrix irregular mapping algorithm, de-sequences the read matrix according to the de-sequence index, and obtains the second encrypted file and the sharding key; Perform RSA decryption processing on the second encrypted file to obtain the first encrypted file, decrypt the first encrypted file based on the shard key and the shard metadata corresponding to the first encrypted file, and reassemble the decrypted shard data into a complete picture or video file according to the shard index and the shard metadata.
2. A method for encrypting, storing and decrypting pictures or videos according to claim 1, characterized in that: The step of parsing and AES encrypting each shard data in the shard set also includes: The key used for AES encryption of each of the slice data is generated based on the slice metadata.
3. A method for encrypting, storing and decrypting pictures or videos according to claim 1, characterized in that: The segment metadata includes file format, timestamp information and segment sequence.
4. A method for encrypting, storing and decrypting pictures or videos according to claim 3, characterized in that: In the step of generating the first encrypted file based on the combination of the encrypted shard data and the shard metadata, the order of the combination is consistent with the shard index.
5. A method for encrypting, storing and decrypting pictures or videos according to claim 1, characterized in that: The step of generating a key matrix based on the number of shard keys, filling the shard keys into the key matrix, and generating a desequence index at the same time also includes: The de-sequenced index is generated based on the coordinates of the key matrix filled with the shard key, and the de-sequenced index is a bidirectional index.
6. A method for encrypting, storing and decrypting pictures or videos according to claim 1, characterized in that: When the terminal performs an acquisition session with the server, the step of generating an empty data matrix as a reading matrix by the terminal further includes: When requesting a session with the server, the server will return a session identifier and generate a session identifier key for interactive matching. The session identifier is encrypted data, and the session identifier key is randomly generated by the server. The session identifier is time-limited.
7. A method for encrypting, storing and decrypting pictures or videos according to claim 6, characterized in that: The step of generating an empty data matrix as a read matrix, filling the read matrix based on a key matrix irregular mapping algorithm, de-sequencing the read matrix according to the de-sequencing index, and obtaining the second encrypted file and the sharding key also includes: The read matrix is formed by irregular mapping of the key matrix and has a time limit. When the interaction with the server exceeds a preset time, the key matrix will modify the mapping address.
8. A method for encrypting, storing and decrypting pictures or videos according to claim 7, characterized in that: The step of generating an empty data matrix as a read matrix, filling the read matrix based on a key matrix irregular mapping algorithm, de-sequencing the read matrix according to the de-sequencing index, and obtaining the second encrypted file and the sharding key also includes: When the session identifier changes, the key matrix will modify the mapping address.
9. A method for encrypting, storing and decrypting pictures or videos according to claim 1, characterized in that: The step of dividing the image or video data information into slices of different storage capacity sizes based on the server performance parameters to obtain a slice set also includes: When the average time it takes for the server to send data is longer than the preset transmission time, the number of slices into which the image or video data is segmented is reduced; When the average time it takes for the server to send data is less than the preset transmission time, the number of slices into which the image or video data is segmented is increased.
10. A picture or video encryption storage and decryption system, characterized in that: include: A data segmentation module (10) is used to segment the image or video data information into segments of different storage capacity sizes based on server performance parameters to obtain a segment set; A shard parsing and encryption module (20) is used to parse and AES encrypt each shard data in the shard set, parse to obtain shard metadata, AES encrypt to obtain encrypted shard data and shard keys, and generate a shard index based on the shard metadata; A slice metadata combination module (30), used to generate a first encrypted file based on the encrypted slice data and the slice metadata combination; A communication encryption module (40) is used to use an RSA encryption algorithm to perform communication encryption on a plurality of the first encrypted files, generate a plurality of second encrypted files accordingly, and upload the sharding key and the second encrypted files to a server; A key de-sequencing generation module (50) is used to generate a key matrix based on the number of shard keys, fill the shard keys into the key matrix, and generate a de-sequencing index at the same time; A reading matrix generating module (60), used for generating an empty data matrix as a reading matrix when the terminal is acquiring a session with the server, filling the reading matrix based on a key matrix irregular mapping algorithm, de-sequencing the reading matrix according to the de-sequencing index, and acquiring the second encrypted file and the sharding key; The shard de-sequencing and combining module (70) is used to perform RSA decryption processing on the second encrypted file to obtain the first encrypted file, decrypt the first encrypted file based on the shard key and the shard metadata corresponding to the first encrypted file, and reassemble the decrypted shard data into a complete picture or video file according to the shard index and the shard metadata.
Citation Information
Patent Citations
Data transmission method for short video fragment uploading
CN115988241A
Method for storing and transmitting video file
CN104836656A
Fine grained streaming media video encryption and decryption method based on HLS protocol
CN106790074A
Video image splitting encryption transmission method, device and system
CN110996132A
Video data transmission method, video data receiving method, server and client
CN112738560A
