File transmission method, device and storage medium based on private transmission protocol
By using the Huffman algorithm and GZIP compression algorithm to compress files during file transfer, and encrypting file transfer instructions and compressed files, the problem of file transfer security and efficiency in private transfer protocols is solved, and more efficient and secure file transfer is achieved.
Patent Information
- Application Number
- CN202410826269.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-06-25
AI Technical Summary
When using a private transfer protocol for file transfer, data may be intercepted and decrypted during transmission and the transmission efficiency is inefficient.
Connect to the receiving node through an external protocol load key, compress files using the Huffman algorithm and GZIP compression algorithm, and encrypt file transfer instructions and compressed files based on preset encryption schemes, and transmit them using network security private protocol, file protocol and asynchronous multi-threaded model.
The file security and transmission efficiency during file transfer are improved, and the overall transmission efficiency can be improved by 17%-21% compared with the prior art, and the file transfer efficiency is improved while ensuring security.
Smart Images

Figure CN118694757B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of secure data transmission, and in particular, relates to a file transmission method, device and storage medium based on a private transmission protocol. Background Art
[0002] Private transfer protocols usually refer to protocols that are customized and developed for specific applications or internal needs of an organization. In modern society, with the surge in data volume and the increase in information security requirements, file transfer based on private transfer protocols has become an important option for enterprises and individuals to consider when transferring data. Private protocols can be customized according to the specific needs of an organization, including supporting specific file types, data formats, and processing logic, thereby providing more accurate and efficient data processing capabilities.
[0003] However, during the data transmission process of private protocols, if encryption measures are not in place, the data may be intercepted and decrypted during transmission. Unencrypted and unverified data may be tampered with during transmission, resulting in damage to data integrity. In addition, after the file is encrypted, there will be a problem of low transmission efficiency before transmission.
[0004] Therefore, in the process of using private transmission protocols for file transfer, how to ensure the safe and efficient transmission of files has become an urgent problem that needs to be solved. Summary of the invention
[0005] The present application provides a file transmission method, device and storage medium based on a private transmission protocol, which effectively improves the file security and file transmission efficiency during the file transmission process.
[0006] In the first aspect, an embodiment of the present application provides a file transfer method based on a private transmission protocol, which is used for a sending node, and the sending node is connected to the receiving node through an external protocol load key, and the external protocol is used for information exchange between the sending node and the receiving node during the handshake phase, and the method includes: obtaining a file to be transmitted and a file transfer instruction; based on the file to be transmitted, the Huffman algorithm and the GZIP compression algorithm, determining the compression time of the file to be transmitted and the transmission time of compression saving space; when the compression time of the file to be transmitted is less than the transmission time of compression saving space, compressing the file to be transmitted to obtain a compressed file; based on a preset encryption scheme, encrypting the file transfer instruction and the compressed file respectively to obtain a first encryption instruction and a first encrypted file; sending the first encryption instruction and the first encrypted file to the receiving node through a network security private protocol, a file protocol and an asynchronous multi-threaded model; receiving a file transfer completion instruction from the receiving node.
[0007] In a possible implementation, the method further includes: receiving missing file identification information from the receiving node; determining the missing file corresponding to the missing file identification information based on the missing file identification information; and sending the missing file to the receiving node based on the file protocol.
[0008] In a possible implementation, the file transfer instruction and the compressed file are encrypted based on a preset encryption scheme and a preset encoding scheme to obtain a first encrypted instruction and a first encrypted file, including: encoding the file transfer instruction into an instruction stream based on the file transfer instruction and the preset encoding scheme; encrypting the instruction stream based on the instruction stream and the preset encryption scheme to determine an encrypted instruction stream; calculating an identification code corresponding to the encrypted instruction stream; and obtaining the first encrypted instruction based on the encrypted instruction stream and the identification code corresponding to the encrypted instruction stream.
[0009] In a possible implementation, the file transfer instruction and the compressed file are encrypted respectively based on a preset encryption scheme to obtain a first encryption instruction and a first encrypted file, including: based on the compressed file and a preset fragmentation rule, the compressed file is divided into multiple fragment files, and the multiple fragment files contain different fragment identifiers; based on the multiple fragment files and the preset encryption scheme, multiple encrypted fragment files are determined; an identification code corresponding to each of the encrypted fragment files is calculated; and the first encrypted file is obtained based on each of the multiple encrypted fragment files and the identification code corresponding to each of the multiple encrypted fragment files.
[0010] In one possible implementation, the preset fragmentation rules include: based on the compressed file, obtaining the size of the compressed file; when the size of the compressed file is greater than 50MB, fragmenting the compressed file to obtain the multiple fragment files, and the size of any fragment file among the multiple fragment files is less than or equal to 5MB.
[0011] In the second aspect, an embodiment of the present application provides a file transfer method based on a private transmission protocol, which is applied to a receiving node, and the method includes: receiving a first encryption instruction and a first encrypted file from a sending node; obtaining a file transfer instruction based on the first encryption instruction and the instruction decryption model; determining a decrypted file based on the first encrypted file and the file decryption model; determining whether the decrypted file is complete based on a missing file detection algorithm; and sending a file transfer completion instruction to the sending node when it is determined that the decrypted file is complete.
[0012] In a possible implementation manner, the method further includes: when it is determined that the decrypted file is incomplete, sending missing file identification information to the sending node; and receiving the missing file from the sending node.
[0013] In the third aspect, an embodiment of the present application provides a file transfer device based on a private transmission protocol, which is applied to a sending node, and the sending node is connected to the receiving node through an external protocol load key, and the external protocol is used for information exchange between the sending node and the receiving node in the handshake phase, and the device includes: an acquisition module, used to obtain a file to be transmitted and a file transfer instruction; a determination module, used to determine the compression time of the file to be transmitted and the transmission time of compression space saving based on the file to be transmitted, the Huffman algorithm and the GZIP compression algorithm; a judgment module, used to compress the file to be transmitted when the compression time of the file to be transmitted is less than the transmission time of compression space saving, and obtain a compressed file; a processing module, used to encrypt the file transfer instruction and the compressed file respectively based on a preset encryption scheme, and obtain a first encryption instruction and a first encrypted file; a sending module, used to send the first encryption instruction and the first encrypted file to the receiving node through a network security private protocol, a file protocol and an asynchronous multi-threaded model; a receiving module, used to receive a file transfer completion instruction from the receiving node.
[0014] In a fourth aspect, an embodiment of the present application provides a file transfer device based on a private transfer protocol, which is applied to a receiving node, and the device includes: a receiving module, which is used to receive a first encryption instruction and a first encrypted file from a sending node; a decryption module, which is used to obtain a file transfer instruction based on the first encryption instruction and the instruction decryption model; the decryption module is also used to determine the decrypted file based on the first encrypted file and the file decryption model; a determination module is used to determine whether the decrypted file is complete based on a missing file detection algorithm; and a sending module is used to send a file transfer completion instruction to the sending node when it is determined that the decrypted file is complete.
[0015] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in the first aspect or the second aspect or any one of the implementation methods thereof is implemented.
[0016] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect or the second aspect or any one of the implementation methods thereof is implemented.
[0017] In a seventh aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device executes the method described in the first aspect or any one of the implementation methods thereof.
[0018] Compared with the prior art, the embodiments of the present application have the following beneficial effects: random symmetric keys are introduced on the basis of asymmetric key mutual trust, and a specific EPPC protocol load is used to enable the sending node and the receiving node to communicate and connect, and an asynchronous multi-threaded model is adopted to encrypt and transmit the file to be transmitted and the file transfer instruction at the same time, thereby improving the security of the file; before transmitting the file, the size of the file to be transmitted is first judged, and when the compression time of the file to be transmitted is less than the transmission time of the compression space saving, the file is compressed. Under this strategy, compared with the prior art of directly compressing all files without classifying them, the overall transmission efficiency can be improved by 17%-21%; after the file is compressed, the file is fragmented. According to the preset fragmentation rule, the compressed file is fragmented only when the size of the compressed file is greater than 50MB, and the size of any fragment file among the multiple fragment files is less than or equal to 5MB. Under this rule, the fragmentation rate and the file transmission rate can be well coordinated through the multi-threaded method, and the fragmentation rate is maximized under the premise of ensuring memory security and system availability, which improves the efficiency by about 20% compared with the traditional solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 A flowchart of a file transmission method based on a private transmission protocol provided in one embodiment of the present application;
[0021] Figure 2 A flowchart of another file transmission method based on a private transmission protocol provided in an embodiment of the present application;
[0022] Figure 3 A communication interaction diagram of a file transmission method based on a private transmission protocol provided in an embodiment of the present application;
[0023] Figure 4 A communication interaction diagram of another file transmission method based on a private transmission protocol provided in an embodiment of the present application;
[0024] Figure 5 A structural block diagram of a file transmission device based on a private transmission protocol provided in one embodiment of the present application;
[0025] Figure 6A structural block diagram of another file transmission device based on a private transmission protocol provided in an embodiment of the present application;
[0026] Figure 7 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0027] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0028] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0029] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0030] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0031] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0032] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0033] In modern society, with the surge in data volume and the increase in information security requirements, file transfer based on private transfer protocols has become an important option for enterprises and individuals to consider when transferring data. However, during the data transfer process of private protocols, if encryption measures are not in place, data may be intercepted and decrypted during transmission. Currently, file transfer through private protocols has the following defects:
[0034] (1) When the sending node and the receiving node establish a connection, the public key generated by the receiving node is sent to the sending node through instructions. There is a possibility of being stolen during the sending process;
[0035] (2) Encryption is performed only through a key, and no encryption is performed during file transmission, resulting in low security during the transmission process;
[0036] (3) During the file transfer process, all files to be transferred are not differentiated and are uniformly compressed and fragmented. Some files that are not suitable for compression and fragmentation will affect the overall file transfer efficiency.
[0037] In response to the above problems, the present application proposes a file transmission method, device and storage medium based on a private transmission protocol.
[0038] For ease of understanding, the technical solution of the present application will be described in detail below with reference to the accompanying drawings.
[0039] First, explain the private protocol:
[0040] Private Protocol Cybersecurity (PPC): used for formal system command communications, using random symmetric key encryption, with high security. The protocol mainly carries system operation command data.
[0041] External Private Protocol Cybersecurit (EPPC): used for information exchange in the handshake phase, encrypted using the default symmetric key. The protocol mainly carries data and keys when the system establishes a connection.
[0042] File Private Protocol Cybersecurit (FPPC): used for file communication, using random symmetric key encryption, high security, concise protocol, no encoding, more efficient, mainly load file streams.
[0043] The design of the private three-layer protocol architecture (EPPC, PPC, FPPC) has an independent structural design for each layer of the protocol. Different protocols are adopted in different communication stages to ensure the security of the entire communication, making the overall structure of the protocol more complex and greatly increasing the difficulty of cracking.
[0044] Figure 1 A flowchart of a file transmission method based on a private transmission protocol provided in an embodiment of the present application is provided, and the method is applied to a sending node. The sending node is connected to a receiving node through an external protocol load key, and the external protocol is used for information exchange during the handshake phase between the sending node and the receiving node.
[0045] In one possible implementation, before the receiving node and the sending node establish a trust connection, the RSA encryption algorithm is used to generate an asymmetric key, that is, a set of public and private keys for identity authentication is generated at the receiving node. The public key is written into the dongle, and after the sending node obtains the dongle, it can connect to the receiving node.
[0046] The generated public key is written into the encryption dongle. After the sending node obtains the encryption dongle, it connects with the receiving node to reduce the risk of network transmission leakage. In addition, the sending node only needs to obtain the encryption dongle once and does not need to obtain it again during subsequent file transmissions, which reduces the number of interactions and improves the security of communication.
[0047] Furthermore, on the basis of mutual trust between the sending node and the receiving node through asymmetric keys, the EPPC protocol load is used and encrypted with random symmetric keys to ensure the security of key exchange, and each connection has a certain degree of randomness, which increases the difficulty of cracking. The random key is generated using the Advanced Encryption Standard (AES) algorithm.
[0048] Furthermore, both nodes have the symmetric key of this connection, complete the information exchange in the handshake phase between the sending node and the receiving node, and can conduct formal communication of the private protocol. The specific methods include:
[0049] S110, obtaining a file to be transferred and a file transfer instruction.
[0050] In a possible implementation, after the sending node and the receiving node complete handshake, the sending node obtains the file to be transmitted and the file transmission instruction.
[0051] S120, based on the file to be transmitted, the Huffman algorithm and the GZIP compression algorithm, determine the compression time of the file to be transmitted and the transmission time of the compressed space saving.
[0052] For example, the file to be transmitted is based on N bits as the basic unit, and the frequency of occurrence of different permutations and combinations of N bits in the file to be transmitted is counted, and there are M=2 N After counting, a frequency set S containing M frequencies will be obtained. S is used to obtain a new code length set LS corresponding to the M combinations through the Huffman algorithm. By accumulating LS and S, the size of the compressed file T1 can be preliminarily obtained. In order to ensure that the compression benefit is positive, the compression rate P can be calculated. The size of the compressed file T1 is divided by the original file size T0 to obtain the compression rate P. The compression rate P is compared with the original compression algorithm to measure the efficiency of the compression rate algorithm.
[0053] The actual compression process uses the GZIP compression algorithm to compress the file. Taking the average compression rate v0 of the GZIP algorithm and combining it with the original file size T0, the predicted compression time can be calculated as t0 = T0 / v0, that is, the time it takes to compress the file to be transmitted. The system will continuously adjust and update v0 based on historical compression records to make the prediction more reliable.
[0054] Furthermore, it can be determined that the size of the space saved by compression is T2=T0-T1, and the transmission time of the compressed space saved is t1=T2 / v1, where v1 can be obtained by testing by deploying the protocol in a real environment.
[0055] S130: When the time consumed to compress the file to be transmitted is less than the transmission time consumed by the compression to save space, the file to be transmitted is compressed to obtain a compressed file.
[0056] Specifically, when t1 is greater than t0*k (k is an adjustment parameter), the file is compressed to obtain a compressed file. According to this compression scheme, combined with the local environment and past transmission data, the parameters are continuously adjusted, and the overall transmission efficiency can be improved by 17%-21%.
[0057] S140, based on a preset encryption scheme, encrypt the file transfer instruction and the compressed file respectively to obtain a first encrypted instruction and a first encrypted file.
[0058] In one possible implementation, based on a preset encryption scheme and a preset coding scheme, a file transfer instruction and a compressed file are encrypted to obtain a first encrypted instruction and a first encrypted file, including: based on the file transfer instruction and the preset coding scheme, encoding the file transfer instruction into an instruction stream; based on the instruction stream and the preset encryption scheme, encrypting the instruction stream to determine the encrypted instruction stream; calculating an identification code corresponding to the encrypted instruction stream; and obtaining the first encrypted instruction based on the encrypted instruction stream and the identification code corresponding to the encrypted instruction stream.
[0059] Exemplarily, the file transfer instructions are encoded and decoded, the preset encoding scheme uses a simple and efficient Protobuf framework for encoding, and the preset encryption scheme uses a random symmetric key generated by an ASE algorithm for encryption, ensuring security while ensuring the efficiency of encryption and decryption.
[0060] Furthermore, the identification code corresponding to the encrypted instruction stream is calculated, including: calculating the message authentication code (Media Access Control, MAC) of the encrypted instruction stream, that is, the MAC value. The MAC value calculation method can adopt the HmacSHA256 algorithm. The MAC value is essentially a function of the data stream and the key. The protocol uses the previously generated symmetric key as the key for calculating the MAC value. This key is only owned by the two connected parties, so it can be used to verify whether the data is sent by the other node. Any behavior of changing the data packet in the middle will cause its MAC value to change. This can be used to ensure that the data packet is complete and has not been tampered with. Based on the encrypted instruction stream and the identification code corresponding to the encrypted instruction stream, a first encrypted instruction is obtained, including: merging the MAC value of the encrypted instruction stream and the encrypted instruction stream to obtain the first encrypted instruction.
[0061] In another possible implementation, the file transfer instruction and the compressed file are encrypted respectively based on a preset encryption scheme to obtain a first encryption instruction and a first encrypted file, including: based on the compressed file and a preset fragmentation rule, dividing the compressed file into multiple fragment files, and the multiple fragment files contain different fragment identifiers; based on the multiple fragment files and the preset encryption scheme, determining multiple encrypted fragment files; calculating an identification code corresponding to each encrypted fragment file; and obtaining the first encrypted file based on each of the multiple encrypted fragment files and the identification code corresponding to each of the multiple encrypted fragment files.
[0062] Exemplarily, the compressed file itself is a character stream, and no encoding process is required in the process of obtaining the first encrypted file, thereby improving efficiency.
[0063] Specifically, in the process of sharding compressed files, the array pool method is used to read files while sharding them. After each shard is completed, subsequent processing is immediately performed, that is, the sharded files are marked and encrypted. When sharding compressed files, the size of the array pool is reasonably set according to the size of the local memory. When there is an available array in the array pool, sharding is performed, otherwise wait. After the sharding process is completed, the array pool resources are returned. Through this method, the sharding rate and the transmission rate can be better coordinated, and the maximum sharding rate can be achieved under the premise of ensuring the availability of the memory security system.
[0064] In one possible implementation, the preset fragmentation rules include: based on the compressed file, obtaining the size of the compressed file; when the size of the compressed file is greater than 50MB, fragmenting the compressed file to obtain multiple fragment files, and the size of any fragment file among the multiple fragment files is less than or equal to 5MB.
[0065] Exemplarily, based on the compressed file, the size of the compressed file is obtained. When the compressed file is less than 50MB, sharding it will affect the overall file transfer efficiency, so the default is that files less than 50MB are not sharded. After testing and verification, the efficiency is highest under 5MB shards. Therefore, in the compressed file sharding process, except for the last shard that is less than or equal to 5MB, the remaining shards are all 5MB. The sharding method adopts a multi-threaded model, and multiple threads read the shards at the same time. Combined with the preset sharding rules and the array pool sharding method, the efficiency can be improved by about 20% compared with the traditional solution.
[0066] Furthermore, after the compressed file is divided into slices, the slices are marked. An example of the identification of the slice file is: if the compressed file is divided into n slices, the set H corresponding to the n slices includes: "n1, size1" "n2, size2" ... "nn, sizen". Sizen represents the size of the nth slice, and nn represents the sequence number.
[0067] Furthermore, the shard file containing the shard identifier is encrypted using a random symmetric key generated by the ASE algorithm to ensure security while ensuring encryption and decryption efficiency.
[0068] Further, calculating the identification code corresponding to each encrypted slice file includes: calculating the MAC value of each slice, and the MAC value calculation method can use the HmacSHA256 algorithm. Based on each of the multiple encrypted slice files and the identification code corresponding to each of the multiple encrypted slice files, obtaining the first encrypted file includes: fusing the MAC value of each slice and each of the multiple encrypted slice files to obtain the first encrypted file.
[0069] S150, sending a first encryption instruction and a first encrypted file to a receiving node through a network security private protocol, a file protocol and an asynchronous multi-threaded model.
[0070] Exemplarily, a first encryption instruction is sent to a receiving node via a network security private protocol and an asynchronous multi-threaded model; and a first encrypted file is sent to a receiving node via a file protocol and an asynchronous multi-threaded model.
[0071] In a possible implementation, the method further includes: receiving missing file identification information from a receiving node; determining the missing file corresponding to the missing file identification information based on the missing file identification information; and sending the missing file to the receiving node based on a file protocol.
[0072] Exemplarily, the remaining sequence numbers of set H are received, and the sending node determines the missing shard file identification information and the corresponding shard file based on the remaining sequence numbers of set H, and then sends the missing file to the receiving node through the file protocol, that is, sends the missing shard file.
[0073] S160, receiving a file transfer completion instruction from a receiving node.
[0074] Exemplarily, when the file transfer is completed, the sending node receives a file transfer completion instruction from the receiving node.
[0075] Figure 2 A flowchart of another file transmission method based on a private transmission protocol provided in an embodiment of the present application, the method is applied to a receiving node, including:
[0076] S210, receiving a first encryption instruction and a first encrypted file from a sending node.
[0077] Exemplarily, the receiving node receives the first encryption instruction and the first encrypted file from the sending node, authenticates the first encryption instruction and the first encrypted file, and then obtains the file transfer instruction and the decrypted file after the authentication is passed.
[0078] S220, obtaining a file transfer instruction based on the first encryption instruction and the instruction decryption model.
[0079] Exemplarily, after the authentication is passed, the MAC value in the first encryption instruction is verified, and the MAC value of the encryption instruction stream is recalculated. The MAC value calculation method can use the HmacSHA256 algorithm. If it does not match, it means that the first encryption instruction is not from a legitimate source or has been tampered with or lost data. In this case, the first encryption instruction is discarded and re-requested. If it matches, it is decrypted according to the random symmetric key generated by the ASE algorithm to obtain the file transfer instruction.
[0080] S230: Determine a decrypted file based on the first encrypted file and the file decryption model.
[0081] Exemplarily, the process of obtaining the decrypted file is consistent with the process of obtaining the file transfer instruction, and will not be repeated here.
[0082] S240: Determine whether the decrypted file is complete based on a missing file detection algorithm.
[0083] Exemplarily, after decryption of the segmented files is completed, the segmented files are merged according to the identifiers of the segmented files, and the missing segments are counted. For example, the missing segments can be counted by hash verification to determine whether all received segments are complete.
[0084] S250: When it is determined that the decrypted file is complete, a file transfer completion instruction is sent to the sending node.
[0085] In a possible implementation, after determining that the received segments are complete, the segments are merged into a complete compressed file, the compressed file is decompressed, and after the decompression is completed, a file transfer completion instruction is sent to the sending node.
[0086] In a possible implementation, when it is determined that the decrypted file is incomplete, missing file identification information is sent to the sending node. After the sending is completed, the missing file is received from the sending node.
[0087] Exemplarily, the set H corresponding to the compressed file divided into n pieces includes: "n1, size1" "n2, size2" ... "nn, sizen". The receiving node receives each piece and determines the size of the piece. If they all match, it removes it from the set H. Finally, the remaining sequence numbers of the set H are those that need to be resent. According to the piece files that need to be resent, the missing file identification information, that is, the remaining sequence numbers of the set H, are sent to the sending node. Receiving is performed according to the missing files sent by the sending node.
[0088] The technical solution provided by the present application is: when establishing a connection, asymmetric encryption and symmetric encryption are used for identity verification and data encryption to ensure the security of each communication. Before transmitting the file, the size of the file to be transmitted is first judged. When the compression time of the file to be transmitted is less than the transmission time of the compression space saving, the file is compressed again, which effectively improves the efficiency of file transmission. Under this strategy, compared with the prior art of directly compressing all files without classification, the overall transmission efficiency can be improved by 17%-21%. During the entire transmission process, the three protocols used improve the security of file transmission. For the compressed file, the fragmented file is fragmented, and after the transmission is completed, the fragmented file is merged to judge its integrity, which improves the efficiency of file transmission and the accuracy of the file after the file transmission is completed. Based on the MAC value, the verification is performed. When the fragmented file is damaged, the MAC value will change. After the MAC value change is detected, the fragment will be retransmitted. After receiving the completion signal of the entire file fragmentation, the missing fragments will be checked. The hash verification algorithm is used to check the missing fragments, and the missing fragments are retransmitted immediately to ensure the integrity of the file to be transmitted.
[0089] Figure 3 is a communication interaction diagram of a file transmission method based on a private transmission protocol provided in an embodiment of the present application, such as Figure 3 As shown, the file transmission method based on the private transmission protocol may include: S301 to S311.
[0090] S301: Obtain a file to be transferred and a file transfer instruction.
[0091] S302: Determine the compression time of the file to be transmitted and the transmission time of compression to save space based on the file to be transmitted, the Huffman algorithm and the GZIP compression algorithm.
[0092] S303: When the time consumed to compress the file to be transmitted is less than the transmission time consumed by the compression to save space, the file to be transmitted is compressed to obtain a compressed file.
[0093] S304: Based on a preset encryption scheme, encrypt the file transfer instruction and the compressed file respectively to obtain a first encrypted instruction and a first encrypted file.
[0094] S305. Send the first encryption instruction and the first encrypted file to the receiving node through the network security private protocol, file protocol and asynchronous multi-threaded model.
[0095] S306: Receive a first encryption instruction and a first encrypted file from a sending node.
[0096] S307: Obtain a file transfer instruction based on the first encryption instruction and the instruction decryption model.
[0097] S308: Determine a decrypted file based on the first encrypted file and the file decryption model.
[0098] S309: Determine whether the decrypted file is complete based on a missing file detection algorithm.
[0099] S310: When it is determined that the decrypted file is complete, a file transfer completion instruction is sent to the sending node.
[0100] S311, receiving a file transfer completion instruction from a receiving node.
[0101] Figure 1 and Figure 2 The content has been described in S301 to S311 and will not be repeated here.
[0102] Figure 4 is a communication interaction diagram of a file transmission method based on a private transmission protocol provided in an embodiment of the present application, such as Figure 4 As shown, the file transmission method based on the private transmission protocol may include: S401 to S415.
[0103] S401: Obtain a file to be transferred and a file transfer instruction.
[0104] S402: Determine the compression time of the file to be transmitted and the transmission time of the compressed file to save space based on the file to be transmitted, the Huffman algorithm and the GZIP compression algorithm.
[0105] S403: When the time consumed to compress the file to be transmitted is less than the transmission time consumed by the compression to save space, the file to be transmitted is compressed to obtain a compressed file.
[0106] S404: Based on a preset encryption scheme, encrypt the file transfer instruction and the compressed file respectively to obtain a first encrypted instruction and a first encrypted file.
[0107] S405: Send the first encryption instruction and the first encrypted file to the receiving node through the network security private protocol, file protocol and asynchronous multi-threaded model.
[0108] S406: Receive a first encryption instruction and a first encrypted file from a sending node.
[0109] S407: Obtain a file transfer instruction based on the first encryption instruction and the instruction decryption model.
[0110] S408: Determine a decrypted file based on the first encrypted file and the file decryption model.
[0111] S409: Determine whether the decrypted file is complete based on a missing file detection algorithm.
[0112] S410: When it is determined that the decrypted file is incomplete, send missing file identification information to the sending node.
[0113] S411. Based on the missing file identification information, determine the missing file corresponding to the missing file identification information.
[0114] S412: Send the missing file to the receiving node based on the file protocol.
[0115] S413: Receive the missing file from the sending node.
[0116] S414: When it is determined that the decrypted file is complete, a file transfer completion instruction is sent to the sending node.
[0117] S415: Receive a file transfer completion instruction from a receiving node.
[0118] Figure 1 and Figure 2 The content has been described in S401 to S415 and will not be repeated here.
[0119] Figure 5 This is a structural block diagram of a file transmission device based on a private transmission protocol provided in this embodiment, which is applied to a signaling node. For the sake of convenience, only the part related to the embodiment of this application is shown. Figure 5 The file transmission device 500 based on the private transmission protocol may include an acquisition module 501, a determination module 502, a judgment module 503, a processing module 504, a sending module 505, and a receiving module 506.
[0120] In one implementation, the apparatus 500 may be used to implement the above Figure 1 For example, the acquisition module 501 is used to implement S110, the determination module 502 is used to implement S120, the judgment module 503 is used to implement S130, the processing module 504 is used to implement S140, the sending module 505 is used to implement S150, and the receiving module 506 is used to implement S160.
[0121] Figure 6 This is a structural block diagram of another file transmission device based on a private transmission protocol provided in this embodiment, which is applied to a receiving node. For the sake of convenience, only the part related to the embodiment of this application is shown. Figure 6 The file transmission device 600 based on the private transmission protocol may include a receiving module 601 , a decryption module 602 , a determination module 603 , and a sending module 604 .
[0122] In one implementation, the apparatus 600 may be used to implement the above Figure 2For example, the receiving module 601 is used to implement S210, the decryption module 602 is used to implement S220 and S230, the determination module 603 is used to implement S240, and the sending module 604 is used to implement S250.
[0123] The technical solution provided by the present application is: when establishing a connection, asymmetric encryption and symmetric encryption are used for identity verification and data encryption to ensure the security of each communication. Before transmitting the file, the size of the file to be transmitted is first judged. When the compression time of the file to be transmitted is less than the transmission time of the compression space saving, the file is compressed again, which effectively improves the efficiency of file transmission. Under this strategy, compared with the prior art of directly compressing all files without classification, the overall transmission efficiency can be improved by 17%-21%. During the entire transmission process, the three protocols used improve the security of file transmission. For the compressed file, the fragmented file is fragmented, and after the transmission is completed, the fragmented file is merged to judge its integrity, which improves the efficiency of file transmission and the accuracy of the file after the file transmission is completed. Based on the MAC value, the verification is performed. When the fragmented file is damaged, the MAC value will change. After the MAC value change is detected, the fragment will be retransmitted. After receiving the completion signal of the entire file fragmentation, the missing fragments will be checked. The hash verification algorithm is used to check the missing fragments, and the missing fragments are retransmitted immediately to ensure the integrity of the file to be transmitted.
[0124] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0125] Figure 7 This is a schematic diagram of the structure of the electronic device provided in this embodiment. Figure 7 As shown, the electronic device 7 of this embodiment includes: at least one processor 70 ( Figure 7 Only one is shown in the figure) a processor, a memory 71, and a computer program 72 stored in the memory 71 and executable on the at least one processor 70, and when the processor 70 executes the computer program 72, the steps in any of the above method embodiments are implemented.
[0126] The electronic device 7 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The electronic device may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will appreciate that Figure 7 It is only an example of the electronic device 7 and does not constitute a limitation on the electronic device 7. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0127] The processor 70 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0128] In some embodiments, the memory 71 may be an internal storage unit of the electronic device 7, such as a hard disk or memory of the electronic device 7. In other embodiments, the memory 71 may also be an external storage device of the electronic device 7, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the electronic device 7. The memory 71 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program. The memory 71 may also be used to temporarily store data that has been output or is to be output.
[0129] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0130] An embodiment of the present application also provides a network device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.
[0131] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0132] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0133] If the 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 present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0134] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0135] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0136] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0137] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0138] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person 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 application, and should all be included in the protection scope of the present application.
Claims
1. A file transmission method based on a private transmission protocol, characterized in that: Applied to a sending node, the sending node is connected to a receiving node through an external protocol, the external protocol is used for information exchange during a handshake phase between the sending node and the receiving node, and carries a key for encrypted communication, the method comprising: Obtain files to be transferred and file transfer instructions; Based on the file to be transmitted, the Huffman algorithm and the GZIP compression algorithm, determine the time consumed for compression of the file to be transmitted and the time consumed for transmission by compression to save space; When the compression time of the file to be transmitted is less than the transmission time of the compressed space saving, the file to be transmitted is compressed to obtain a compressed file; Based on a preset encryption scheme, the file transfer instruction and the compressed file are respectively encrypted to obtain a first encrypted instruction and a first encrypted file; including: based on the file transfer instruction and the preset encoding scheme, encoding the file transfer instruction into an instruction stream; based on the instruction stream and the preset encryption scheme, encrypting the instruction stream to determine an encrypted instruction stream; calculating an identification code corresponding to the encrypted instruction stream; based on the encrypted instruction stream and the identification code corresponding to the encrypted instruction stream, obtaining the first encrypted instruction; Sending the first encryption instruction and the first encrypted file to the receiving node through a network security private protocol, a file protocol and an asynchronous multi-threaded model; Receive a file transfer completion instruction from the receiving node.
2. The file transmission method according to claim 1, characterized in that: The method further comprises: Receiving missing file identification information from the receiving node; Based on the missing file identification information, determining the missing file corresponding to the missing file identification information; Based on the file protocol, the missing file is sent to the receiving node.
3. The file transmission method according to claim 1, characterized in that: The step of encrypting the file transfer instruction and the compressed file based on a preset encryption scheme to obtain a first encrypted instruction and a first encrypted file includes: Based on the compressed file and a preset fragmentation rule, the compressed file is divided into a plurality of fragmentation files, wherein the plurality of fragmentation files contain different fragmentation identifiers; Based on the multiple slice files and the preset encryption scheme, determine multiple encrypted slice files; Calculate the identification code corresponding to each of the encrypted segment files; The first encrypted file is obtained based on each of the plurality of encrypted slice files and the identification code corresponding to each of the plurality of encrypted slice files.
4. The file transmission method according to claim 3, characterized in that: The preset fragmentation rules include: Based on the compressed file, obtaining the size of the compressed file; When the size of the compressed file is greater than 50 MB, the compressed file is fragmented to obtain the multiple fragment files, and the size of any fragment file in the multiple fragment files is less than or equal to 5 MB.
5. A file transmission method based on a private transmission protocol, characterized in that: Applied to a receiving node, the method comprises: Receiving a first encryption instruction and a first encrypted file from a sending node; the first encryption instruction and the first encrypted file are obtained by encrypting a file transfer instruction and a compressed file respectively based on a preset encryption scheme; The method of encrypting the file transfer instruction and the compressed file based on a preset encryption scheme comprises: encoding the file transfer instruction into an instruction stream based on the file transfer instruction and a preset encoding scheme; encrypting the instruction stream based on the instruction stream and the preset encryption scheme to determine an encrypted instruction stream; calculating an identification code corresponding to the encrypted instruction stream; and obtaining the first encrypted instruction based on the encrypted instruction stream and the identification code corresponding to the encrypted instruction stream; Based on the first encryption instruction and the instruction decryption model, obtaining a file transfer instruction; Determine a decrypted file based on the first encrypted file and the file decryption model; Determining whether the decrypted file is complete based on a missing file detection algorithm; When it is determined that the decrypted file is complete, a file transfer completion instruction is sent to the sending node.
6. The file transmission method according to claim 5, characterized in that: The method further comprises: When it is determined that the decrypted file is incomplete, sending missing file identification information to the sending node; A missing file is received from the signaling node.
7. A file transmission device based on a private transmission protocol, characterized in that: Applied to a sending node, the sending node is connected to a receiving node through an external protocol, the external protocol is used for information exchange during the handshake phase between the sending node and the receiving node, and carries a key for encrypted communication, the device comprises: An acquisition module, used to acquire files to be transferred and file transfer instructions; A determination module, used to determine the compression time of the file to be transmitted and the transmission time of compression saving space based on the file to be transmitted, the Huffman algorithm and the GZIP compression algorithm; A judgment module, configured to compress the file to be transmitted to obtain a compressed file when the compression time of the file to be transmitted is less than the transmission time of the compressed space saving; A processing module, configured to encrypt the file transfer instruction and the compressed file based on a preset encryption scheme, respectively, to obtain a first encrypted instruction and a first encrypted file; The method of encrypting the file transfer instruction and the compressed file based on a preset encryption scheme comprises: encoding the file transfer instruction into an instruction stream based on the file transfer instruction and a preset encoding scheme; encrypting the instruction stream based on the instruction stream and the preset encryption scheme to determine an encrypted instruction stream; calculating an identification code corresponding to the encrypted instruction stream; and obtaining the first encrypted instruction based on the encrypted instruction stream and the identification code corresponding to the encrypted instruction stream; A sending module, used for sending the first encryption instruction and the first encrypted file to the receiving node through a network security private protocol, a file protocol and an asynchronous multi-threaded model; The receiving module is used to receive the file transfer completion instruction from the receiving node.
8. A file transmission device based on a private transmission protocol, characterized in that: Applied to a receiving node, the device comprises: A receiving module, used to receive a first encryption instruction and a first encrypted file from a sending node; the first encryption instruction and the first encrypted file are obtained by encrypting the file transfer instruction and the compressed file respectively based on a preset encryption scheme; The method of encrypting the file transfer instruction and the compressed file based on a preset encryption scheme comprises: encoding the file transfer instruction into an instruction stream based on the file transfer instruction and a preset encoding scheme; encrypting the instruction stream based on the instruction stream and the preset encryption scheme to determine an encrypted instruction stream; calculating an identification code corresponding to the encrypted instruction stream; and obtaining the first encrypted instruction based on the encrypted instruction stream and the identification code corresponding to the encrypted instruction stream; A decryption module, used to obtain a file transfer instruction based on the first encryption instruction and the instruction decryption model; The decryption module is further used to determine a decryption file based on the first encrypted file and the file decryption model; A determination module, configured to determine whether the decrypted file is complete based on a missing file detection algorithm; The sending module is used to send a file transfer completion instruction to the sending node when it is determined that the decrypted file is complete.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 or claims 5 to 6 is implemented.
Citation Information
Patent Citations
File transmission method and device, electronic equipment and readable storage medium
CN114338651A