File transmission method and device, computer device and storage medium
By converting files into data input streams and splitting them into arrays for encoding and encryption, the problems of low security and efficiency in traditional file transfer are solved, enabling secure and efficient transfer of extremely large files.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-06-19
- Publication Date
- 2026-06-09
AI Technical Summary
Traditional file transfer solutions cannot guarantee security and are inefficient when transferring very large files, especially in insecure network environments where there is a risk of file interception, and require a lot of caching time.
The file is converted into a data input stream, multiple raw arrays are read and encoded, each array is then encrypted to generate an encrypted array, and the transmission message is determined based on the encryption key. The transmission messages corresponding to the encoded arrays are then transmitted sequentially.
When transferring very large files, it reduces memory usage, improves transfer efficiency, and ensures the security of the transfer process by first encoding and then encrypting.
Smart Images

Figure CN116708411B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data security technology, and in particular to a file transfer method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] As financial services continue to develop, financial institutions need to exchange documents with external stakeholders in addition to internal document exchanges.
[0003] Because the network environment for communication between financial institutions and external stakeholders is complex, traditional techniques typically employ the following methods to enhance file transfer security: first, encrypting the text content line by line; and second, calculating the MD5 (Message-Digest Algorithm 5) value of the file content to prevent tampering. However, the first method only encrypts text files line by line and is unsuitable for transmitting extremely large files. The second method, in insecure network environments, carries the risk of file interception. Furthermore, traditional file transfer processes require buffering time to completely write the text to disk before encryption and decryption can be performed, placing significant demands on memory and disk space and greatly increasing transfer time, especially for extremely large files, leading to low transfer efficiency.
[0004] Therefore, traditional file transfer solutions cannot ensure the security of transferring extremely large files, and require improved transfer efficiency. Summary of the Invention
[0005] Therefore, it is necessary to provide a file transfer method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can ensure the security of the transfer of extremely large files and improve the transfer efficiency, in response to the above-mentioned technical problems.
[0006] Firstly, this application provides a file transfer method. The method includes:
[0007] Convert the file into a data input stream, and read multiple raw arrays corresponding to the file from the data input stream;
[0008] Each original array is encoded separately to obtain the corresponding encoded array for each original array.
[0009] For each encoded array, the encoded array is encrypted to obtain an encrypted array, and the sub-output stream of the encrypted array is determined.
[0010] Based on the sub-output stream and the encryption key used in the encryption process, determine the transmission message corresponding to the encoded array;
[0011] The transmission messages corresponding to each encoded array are transmitted sequentially.
[0012] In one embodiment, encrypting the encoded array yields an encrypted array, including:
[0013] Obtain the randomly generated encryption key;
[0014] The encoded array is encrypted using the encryption key to obtain the encrypted array.
[0015] In one embodiment, the transmission message corresponding to the encoded array is determined based on the sub-output stream and the encryption key used in the encryption process, including:
[0016] Obtain the encryption key used in the encryption process and determine the key information corresponding to the encryption key;
[0017] The sub-output stream and key information are assembled into a message to obtain the transmission message corresponding to the encoded array.
[0018] In one embodiment, determining the key information corresponding to the encryption key includes:
[0019] Obtain the receiver's public key;
[0020] Based on the receiver's public key, the encryption key is encrypted to obtain the key information corresponding to the encryption key.
[0021] In one embodiment, message assembly is performed on the sub-output stream and key information to obtain a transmission message corresponding to the encoded array, including:
[0022] Use the sub-output stream corresponding to the encoded array as the message body of the transmitted message corresponding to the encoded array;
[0023] The header length of the transmitted message corresponding to the encoded array is determined based on the length of the encrypted array corresponding to the sub-output stream.
[0024] Configure the key information as the message header of the transmitted message corresponding to the encoded array, according to the header length;
[0025] Based on the message body and message header, a transmission message corresponding to the encoded array is generated.
[0026] Secondly, this application provides a method for receiving documents. The method includes:
[0027] Receive multiple transmission messages sequentially;
[0028] For each transmitted message, determine the corresponding sub-output stream, the encrypted array output by the sub-output stream, and the encryption key of the encrypted array;
[0029] The encrypted array is decrypted using the encryption key to obtain the encoded array;
[0030] Decode the encoded array to obtain the original array corresponding to the transmitted message;
[0031] Determine the file that matches the original array corresponding to each of the multiple transmission messages.
[0032] In one embodiment, determining the sub-output stream corresponding to the transmitted message, the encrypted array output by the sub-output stream, and the encryption key of the encrypted array includes:
[0033] The transmitted message is split to determine the corresponding sub-output stream, the encryption array output by the sub-output stream, and the key information.
[0034] The key information is decrypted to obtain the encryption key for the encrypted array.
[0035] In one embodiment, the transmitted message is split to determine the sub-output stream corresponding to the transmitted message, the encrypted array output by the sub-output stream, and the key information, including:
[0036] The transmitted message is parsed and processed to obtain the message body and message header.
[0037] Based on the message body and the header length of the message header, obtain the sub-input stream corresponding to the transmitted message and the encrypted array output by the sub-output stream;
[0038] Based on the message header, obtain the key information corresponding to the transmitted message.
[0039] Thirdly, this application provides a file transfer device. The device includes:
[0040] The file conversion module is used to convert files into a data input stream and read multiple raw arrays corresponding to the file from the data input stream;
[0041] The array encoding module is used to encode each original array separately to obtain the corresponding encoded array for each original array.
[0042] The array encryption module is used to encrypt the encoded array for each encoded array to obtain an encrypted array, and to determine the sub-output stream of the encrypted array.
[0043] The message determination module is used to determine the transmission message corresponding to the encoded array based on the sub-output stream and the encryption key used in the encryption process.
[0044] The message transmission module is used to transmit the transmission messages corresponding to each encoded array in sequence.
[0045] In one embodiment, the array encryption module is also used to obtain a randomly generated encryption key; and to encrypt the encoded array based on the encryption key to obtain an encrypted array.
[0046] In one embodiment, the message determination module is further configured to: obtain the encryption key used in the encryption process, determine the key information corresponding to the encryption key; and assemble the sub-output stream and the key information to obtain the transmission message corresponding to the encoded array.
[0047] In one embodiment, the device further includes:
[0048] The key information acquisition module is used to obtain the public key of the receiving end; based on the public key of the receiving end, the encryption key is encrypted to obtain the key information corresponding to the encryption key.
[0049] In one embodiment, the device further includes:
[0050] The message generation module is used to take the sub-output stream corresponding to the encoded array as the message body of the transmitted message corresponding to the encoded array; determine the header length of the transmitted message corresponding to the encoded array based on the length of the encrypted array corresponding to the sub-output stream; configure the key information as the message header of the transmitted message corresponding to the encoded array according to the header length; and generate the transmitted message corresponding to the encoded array based on the message body and message header.
[0051] Fourthly, this application provides a document receiving device, the device comprising:
[0052] The message receiving module is used to receive multiple transmitted messages sequentially;
[0053] The message splitting module is used to determine, for each transmitted message, the corresponding sub-output stream, the encrypted array output by the sub-output stream, and the encryption key of the encrypted array.
[0054] The array decryption module is used to decrypt the encrypted array based on the encryption key to obtain the encoded array;
[0055] The array decoding module is used to decode the encoded array to obtain the original array corresponding to the transmitted message;
[0056] The file determination module is used to determine the file that matches the original array corresponding to each of the multiple transmission messages.
[0057] In one embodiment, the message splitting module is further configured to: split the transmitted message into sub-output streams corresponding to the transmitted message, determine the encrypted array output by the sub-output streams, and the key information; and decrypt the key information to obtain the encryption key of the encrypted array.
[0058] In one embodiment, the device further includes:
[0059] The message parsing module is used to parse and process the transmitted message to obtain the message body and message header; based on the message body and the header length, it obtains the sub-input stream and the encrypted array output by the sub-output stream corresponding to the transmitted message; and based on the message header, it obtains the key information corresponding to the transmitted message.
[0060] Fifthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0061] Convert the file into a data input stream, and read multiple raw arrays corresponding to the file from the data input stream;
[0062] Each original array is encoded separately to obtain the corresponding encoded array for each original array.
[0063] For each encoded array, the encoded array is encrypted to obtain an encrypted array, and the sub-output stream of the encrypted array is determined.
[0064] Based on the sub-output stream and the encryption key used in the encryption process, determine the transmission message corresponding to the encoded array;
[0065] The transmission messages corresponding to each encoded array are transmitted sequentially.
[0066] Sixthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0067] Convert the file into a data input stream, and read multiple raw arrays corresponding to the file from the data input stream;
[0068] Each original array is encoded separately to obtain the corresponding encoded array for each original array.
[0069] For each encoded array, the encoded array is encrypted to obtain an encrypted array, and the sub-output stream of the encrypted array is determined.
[0070] Based on the sub-output stream and the encryption key used in the encryption process, determine the transmission message corresponding to the encoded array;
[0071] The transmission messages corresponding to each encoded array are transmitted sequentially.
[0072] Seventhly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0073] Convert the file into a data input stream, and read multiple raw arrays corresponding to the file from the data input stream;
[0074] Each original array is encoded separately to obtain the corresponding encoded array for each original array.
[0075] For each encoded array, the encoded array is encrypted to obtain an encrypted array, and the sub-output stream of the encrypted array is determined.
[0076] Based on the sub-output stream and the encryption key used in the encryption process, determine the transmission message corresponding to the encoded array;
[0077] The transmission messages corresponding to each encoded array are transmitted sequentially.
[0078] The aforementioned file transfer method, apparatus, computer equipment, storage medium, and computer program product convert a file into a data input stream, reads multiple raw arrays corresponding to the file from the data input stream (i.e., converts and splits the file into arrays), so that the file does not need to be cached during subsequent transmission, thus reducing the memory consumption of the file transfer process. Then, each raw array is encoded to obtain a corresponding encoded array. For each encoded array, the encoded array is encrypted to obtain an encrypted array. Thus, by performing the operation of encoding and then encrypting the raw arrays, the security of the transmission process is further improved. Then, a sub-output stream for outputting the encrypted array is determined. Based on the sub-output stream and the encryption key used in the encryption process, the transmission message corresponding to the encoded array is determined, and the transmission messages corresponding to each encoded array are transmitted sequentially. On the one hand, in scenarios involving the transmission of extremely large files, there's no need to cache or directly process them. Instead, the large file is converted and split into arrays for processing. These processed arrays are then converted into output streams and assembled into transmission messages, which are then transmitted sequentially. This reduces memory usage and improves transmission efficiency. On the other hand, the security of the transmission process is enhanced through encoding followed by encryption and the assembly of transmission messages. Therefore, this entire process can meet the transmission needs of extremely large files, ensuring both security and efficiency. Attached Figure Description
[0079] Figure 1 This is a diagram illustrating the application environment of a file transfer method in one embodiment.
[0080] Figure 2This is a flowchart illustrating a file transfer method in one embodiment;
[0081] Figure 3 This is a schematic diagram of the process for obtaining an encrypted array in one embodiment;
[0082] Figure 4 This is a schematic diagram of the process for determining the transmitted message in one embodiment;
[0083] Figure 5 This is a flowchart illustrating the process of determining key information in one embodiment;
[0084] Figure 6 This is a schematic diagram of the process of assembling and transmitting messages in one embodiment;
[0085] Figure 7 This is a flowchart illustrating a file receiving method in one embodiment;
[0086] Figure 8 This is a flowchart illustrating the process of splitting transmission messages in one embodiment;
[0087] Figure 9 This is a flowchart illustrating the process of parsing transmitted messages in one embodiment;
[0088] Figure 10 This is a flowchart illustrating the combination of a file transfer method and a file receiving method in another embodiment;
[0089] Figure 11 This is a structural block diagram of a file transfer device in one embodiment;
[0090] Figure 12 This is a structural block diagram of a file receiving device in one embodiment;
[0091] Figure 13 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0092] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0093] It should be noted that the file information, file sending end information, file receiving end information (including but not limited to information within the file, sending end device information, receiving end device information, key information, etc.) and file data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the users of each end or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0094] The file transfer method provided in this application embodiment can be applied to, for example, Figure 1 The file transfer system shown in the diagram includes a sender 102 communicating with a receiver 104 via a network. A data storage system can store the data that both the sender 102 and receiver 104 need to process. The data storage system can be integrated into both the sender 102 and receiver 104, or it can be located in the cloud or on another network server. The sender 102 can convert the file into a data input stream, read multiple raw arrays corresponding to the file from the data input stream, encode each raw array separately to obtain its corresponding encoded array, and encrypt each encoded array to obtain an encrypted array. The sender 102 can then determine the sub-output stream that outputs the encrypted array, and based on the sub-output stream and the encryption key used in the encryption process, determine the transmission message corresponding to each encoded array, and then sequentially transmit the corresponding transmission messages of each encoded array to the receiver 104.
[0095] The sending end 102 can be, but is not limited to, various terminal devices capable of transmitting data, such as personal computers, laptops, smartphones, and tablets. The receiving end 104 can be, but is not limited to, various servers capable of receiving data, and can be implemented using a standalone server or a server cluster composed of multiple servers. Taking the fintech field as an example, the sending end 102 can be a terminal of a financial institution or a terminal of an external party that needs to interact with the financial institution, and the receiving end 104 can be a server of a financial institution or a server of an external party that needs to interact with the financial institution, so as to realize file transfer within the financial institution and between the financial institution and external parties based on the file transfer method provided in this embodiment.
[0096] In one embodiment, such as Figure 2 As shown, a file transfer method is provided, which can be applied to... Figure 1 Taking the sending end in the example, the explanation includes the following steps:
[0097] Step 202: Convert the file into a data input stream and read multiple raw arrays corresponding to the file from the data input stream.
[0098] Specifically, the data input stream can be the most basic input stream provided by the Java standard library, namely the byte input stream (InputStream). The array can be a byte array (Byte array).
[0099] Optionally, the sending end can obtain input bytes from the file to be transmitted, and generate a data input stream based on the obtained input bytes. Then, according to the data arrangement order in the data input stream, it sequentially reads raw arrays of a preset length from the data input stream to obtain multiple raw arrays corresponding to the file to be transmitted. The preset length of the raw arrays can be flexibly configured according to actual needs.
[0100] For example, the sending end can read a raw array of a preset length from the data input stream according to the data arrangement order in the data input stream, maintaining the same interval each time. The interval between each reading of the raw array can be greater than, equal to, or less than the preset length. When the interval is equal to the preset length, the sending end starts reading the next raw array from the position read in each reading.
[0101] Step 204: Encode each original array separately to obtain the corresponding encoded array for each original array.
[0102] Both the original array and the encoded array are byte arrays. Encoding algorithms can include Base64 encoding, ASCII encoding, UTF-8 encoding, etc. Base64 encoding is a method of converting binary data into ASCII characters; ASCII encoding is a character encoding method based on the Latin alphabet; and UTF-8 encoding is a variable-length Unicode encoding method. The encoding algorithms involved in this embodiment can be flexibly configured according to the actual application scenario and are not limited to the above-mentioned types.
[0103] Optionally, the sending end can encode each original array separately using the same encoding algorithm to obtain the corresponding encoded array for each original array, or it can encode each original array separately using different encoding algorithms. However, after encoding the original array, the length of the resulting encoded array will not be the same as the length of the original array; the array length will increase. That is, the number of bytes corresponding to a certain original array will be less than the number of bytes in the encoded array obtained by encoding that original array.
[0104] For example, taking the sending end as an example of encoding each original array separately based on the same encoding algorithm, the sending end can encode each original array separately based on any of the encoding methods such as Base64 encoding, ASCII encoding, and UTF-8 encoding to obtain the corresponding encoded array of each original array.
[0105] For example, taking the sending end as an example of encoding each original array separately based on different encoding algorithms, the sending end can encode each original array separately based on at least two of the encoding methods such as Base64 encoding, ASCII encoding, and UTF-8 encoding.
[0106] Step 206: For each encoded array, encrypt the encoded array to obtain an encrypted array, and determine the sub-output stream of the encrypted array.
[0107] Among them, the sub-output stream is the most basic output stream provided by the Java standard library, namely the byte output stream (OutputStream).
[0108] Optionally, the sending end can encrypt each encoded array separately using the same encryption method to obtain a corresponding encrypted array for each encoded array, or it can encrypt each encoded array separately using different encryption methods to obtain a corresponding encrypted array for each encoded array. Furthermore, for each encrypted array, the sending end can determine a sub-output stream of the output encrypted array. Note that after encrypting the encoded array, the length of the resulting encrypted array is not the same as the length of the encoded array; the array length will increase, meaning the number of bytes corresponding to a certain encoded array is less than the number of bytes in the encrypted array obtained by encrypting that encoded array.
[0109] Step 208: Based on the sub-output stream and the encryption key used in the encryption process, determine the transmission message corresponding to the encoded array.
[0110] Specifically, the transmitted messages are messages transmitted based on the HTTP (Hypertext Transfer Protocol) protocol, i.e., HTTP messages.
[0111] Optionally, for each encoded array, the sender can determine the sub-output stream corresponding to the encoded array based on the correspondence between the encoded array and the encrypted array, and the correspondence between the encrypted array and the sub-output stream. In this way, the sender can assemble the transmission message corresponding to the encoded array according to the HTTP message format, based on the sub-output stream corresponding to the encoded array and the encryption key used in the process of encrypting the encoded array.
[0112] Step 210: Transmit the transmission messages corresponding to each encoding array in sequence.
[0113] Optionally, the sending end can determine the transmission order of the transmission messages corresponding to each encoded array based on the order in which the original arrays are read from the data input stream, as well as the correspondence between the original arrays and the encoded arrays, and the correspondence between the encoded arrays and the transmission messages. Then, based on the HTTP protocol, the sending end can sequentially transmit the transmission messages corresponding to each encoded array to the receiving end.
[0114] In the aforementioned file transfer method, the file is converted into a data input stream. Multiple raw arrays corresponding to the file are read from the data input stream, essentially converting and splitting the file into arrays. This eliminates the need for file caching during subsequent transfers, minimizing memory consumption. Each raw array is then encoded to obtain its corresponding encoded array. Each encoded array is then encrypted to obtain an encrypted array. This prior encoding and encryption of the raw arrays enhances security. A sub-output stream for the encrypted array is then determined. Based on the sub-output stream and the encryption key used in the encryption process, the corresponding transmission message for each encoded array is determined, and these messages are transmitted sequentially. On one hand, in scenarios involving the transfer of extremely large files, there is no need to cache or directly process them. Instead, the large file is converted and split into arrays for processing, and then the processed arrays are converted into output streams and assembled into transmission messages. This sequential transmission reduces memory usage and improves efficiency. On the other hand, the prior encoding and encryption, along with the message assembly steps, further enhance security during transmission. Therefore, the entire process can meet the transmission needs of extremely large files, ensuring both the security of the transmission process and improving transmission efficiency.
[0115] In one embodiment, such as Figure 3 As shown, the encrypted array is obtained by encrypting the encoded array, including:
[0116] Step 302: Obtain the randomly generated encryption key.
[0117] The methods for randomly generating encryption keys include, but are not limited to: random generation based on the AES encryption algorithm (symmetric encryption), random generation based on the RSA encryption algorithm (asymmetric encryption), and random generation based on domestically developed cryptographic algorithms. Domestically developed cryptographic algorithms mainly include SM1 (block cipher), SM2 (elliptic curve public-key cryptography), and SM3 (cryptographic hash algorithm), etc.
[0118] Optionally, the sender may randomly select an encryption algorithm from a variety of encryption algorithms and obtain one or more encryption keys randomly generated based on that encryption algorithm. Alternatively, it may select multiple encryption algorithms and obtain multiple encryption keys generated based on multiple encryption algorithms.
[0119] Step 304: Encrypt the encoded array based on the encryption key to obtain the encrypted array.
[0120] Each encoded array has its own corresponding encrypted array.
[0121] Optionally, if the sending end obtains only one randomly generated encryption key, the sending end can encrypt each encoded array separately based on the random key; if the sending end obtains multiple encryption keys randomly generated based on the same encryption algorithm, or multiple encryption keys randomly generated based on different encryption algorithms, the sending end can encrypt each encoded array separately based on different encryption keys to obtain the corresponding encrypted array for each encoded array.
[0122] For example, the sending end encrypts each encoded array based on different encryption keys. In the process of encrypting a certain encoded array, the sending end can randomly select an encryption key from AES encryption key, RSA encryption key, SM1 encryption key, SM2 encryption key, and SM3 encryption key to encrypt the encoded array. Then, the above random selection step is repeated to select a new encryption key to encrypt the next encoded array.
[0123] In this embodiment, the encoded array is encrypted using a randomly generated encryption key to obtain an encrypted array. This improves the security of the array during transmission, thereby enhancing the security of the sub-output streams derived from the encrypted array, and ultimately improving the security of the transmitted message assembled from the sub-output streams, ensuring secure data transmission. Furthermore, in this embodiment, the encoded array can be encrypted using different random keys, further increasing the complexity and randomness of the generated encrypted array. This, in turn, increases the complexity and randomness of the transmitted message, also contributing to ensuring secure data transmission.
[0124] In one embodiment, such as Figure 4 As shown, based on the sub-output stream and the encryption key used in the encryption process, the transmission message corresponding to the encoded array is determined, including:
[0125] Step 402: Obtain the encryption key used in the encryption process and determine the key information corresponding to the encryption key.
[0126] Specifically, the encryption information corresponding to the encryption key is: the encryption key after encryption processing.
[0127] Optionally, for each encoded array, the sending end can obtain the encryption key used in the encryption process of the encoded array, and encrypt the obtained encryption key to obtain the key information of the encryption key corresponding to the encoded array.
[0128] For example, the sending end can encrypt the encryption key corresponding to each encoding array separately based on the same encryption method to obtain the key information of the encryption key corresponding to each encoding array, or it can encrypt the encryption key corresponding to each encoding array separately based on different encryption methods to obtain the key information of the encryption key corresponding to each encoding array.
[0129] Step 404: Message assembly is performed on the sub-output stream and key information to obtain the transmission message corresponding to the encoded array.
[0130] The transmitted message mainly consists of two parts: the message body and the message header.
[0131] Optionally, for each encoded array, the sender can determine the sub-output stream corresponding to the encoded array based on the correspondence between the encoded array and the encrypted array, and the correspondence between the encrypted array and the sub-output stream, and then assemble the sub-output stream corresponding to the encoded array with the key information to obtain the transmission message corresponding to the encoded array.
[0132] In this embodiment, by assembling messages from the sub-output streams and key information corresponding to the encoded array, a transmission message corresponding to the encoded array is obtained. On the one hand, based on the complexity and randomness of the sub-output streams and key information, a transmission message with higher complexity and randomness can be assembled, which can ensure the security of the transmission message and thus improve the security of data transmission. On the other hand, instead of directly transmitting files, the transmission message assembled based on the sub-output streams and key messages is transmitted, so that the receiving end does not need to spend too much time caching files when receiving data, but only needs to respond to and receive the transmission message, which helps to reduce memory usage and improve data transmission efficiency.
[0133] In one embodiment, such as Figure 5 As shown, the key information corresponding to the encryption key is determined, including:
[0134] Step 502: Obtain the receiver's public key.
[0135] In this system, public and private keys appear in pairs. Data encrypted with the public key can only be decrypted using the private key that corresponds to the public key. The private key that corresponds to the public key at the receiving end is the private key at the receiving end.
[0136] Optionally, the sending end can obtain the CA (Certificate Authority) certificate issued by the key management end to the receiving end, and retrieve the receiving end's public key from the CA certificate. The key management end is responsible for managing the CA certificates issued by the CA, and the CA certificate is the carrier of the key pair (public-private key pair).
[0137] For example, different CAs may issue different CA certificates to the same receiving end. Therefore, the sending end can randomly select a receiving end CA certificate issued by one CA to obtain a receiving end public key, or it can obtain multiple receiving end CA certificates from multiple CAs to obtain multiple receiving end public keys.
[0138] Step 504: Based on the receiver's public key, encrypt the encryption key to obtain the key information corresponding to the encryption key.
[0139] Optionally, if the sending end obtains only one receiver public key, the sending end can encrypt the encryption key corresponding to each encoding array based on the obtained receiver public key to obtain the key information of the encryption key corresponding to each encoding array. If the sending end obtains multiple receiver public keys, for the encryption key corresponding to each encoding array, the sending end can randomly select any receiver public key from the multiple receiver public keys to encrypt the encryption key corresponding to the encoding array. Then, the above random selection step is repeated to select a new receiver public key to encrypt the encryption key corresponding to the next encoding array.
[0140] In this embodiment, the encryption key is encrypted using the receiving end's public key to obtain the corresponding key information. This improves the security of the key information during transmission, thereby enhancing the security of the transmitted message assembled based on the key information and ensuring data transmission security. Furthermore, in this embodiment, the encryption key corresponding to each encoding array can be encrypted separately based on different receiving end public keys. This increases the complexity and randomness of the generated key information, thereby increasing the complexity and randomness of the transmitted message and further contributing to ensuring data transmission security.
[0141] In one embodiment, such as Figure 6 As shown, message assembly is performed on the sub-output stream and key information to obtain the transmission message corresponding to the encoded array, including:
[0142] Step 602: Use the sub-output stream corresponding to the encoding array as the message body of the transmission message corresponding to the encoding array.
[0143] Optionally, for each encoded array, the sender can determine the corresponding sub-output stream based on the correspondence between the encoded array and the encrypted array, and the correspondence between the encrypted array and the sub-output stream. The sub-output stream corresponding to the encoded array is then used as the message body of the transmitted message corresponding to the encoded array. Specifically, the transmitted message is an HTTP message, and the message body is the HTTP body.
[0144] Step 604: Determine the header length of the transmission message corresponding to the encoded array based on the length of the encrypted array corresponding to the sub-output stream.
[0145] The length of the encrypted array is specifically the number of bytes in the encrypted array, and the header length is specifically the number of bytes that the message header can hold.
[0146] Optionally, for each encoded array, after determining the sub-output stream corresponding to the encoded array, the sender can determine the header length of the transmitted message corresponding to the encoded array based on the length of the encrypted array corresponding to the sub-output stream.
[0147] Step 606: Configure the key information into the message header of the transmission message corresponding to the encoded array, according to the header length.
[0148] Optionally, for each encoded array, after determining the header length of the transmission message corresponding to the encoded array, the sender can configure the key information as the message header of the transmission message corresponding to the encoded array according to the header length. Specifically, the transmission message is an HTTP message, and the message header of the transmission message is an HTTP header.
[0149] For example, to ensure that the message header can contain the configured key information, the number of bytes that the message header can hold—that is, the header length—cannot be less than the number of bytes of the key information, meaning the number of bytes in the encrypted array cannot be less than the number of bytes of the key information. The length of the encoded array is greater than the length of the original array, and the length of the encrypted array is greater than the length of the original array. Therefore, before reading the original array, the sending end can configure the preset length of the read original array to a larger value to ensure that the number of bytes in the encrypted array is not less than the number of bytes of the key information.
[0150] For example, taking the case where the number of bytes in the encrypted array corresponding to a certain encoded array is C bytes (abbreviated as B), the sending end can first determine that the header length of the message header corresponding to the encoded array is also C bytes. When the number of bytes in the key information is less than C bytes, that is, when the header length of the message header is greater than the number of bytes in the key information, the sending end can add the complete key information to the message header and pad it with 0 to obtain a message header of C bytes; when the number of bytes in the key information is equal to C bytes, the sending end can use the complete key information as the message header.
[0151] Step 608: Generate the transmission message corresponding to the encoded array based on the message body and message header.
[0152] Optionally, for each encoded array, the sender can generate a transmission message corresponding to the encoded array by assembling the configured message body and message header.
[0153] In this embodiment, by assembling the sub-output stream corresponding to the encoding array, the length of the encryption array corresponding to the sub-output stream, and the key information corresponding to the encoding array, the transmission message corresponding to the encoding array is obtained. Based on the complexity and randomness of the sub-output stream and key information, a transmission message with higher complexity and randomness can be assembled, which can improve the security of the transmission message and thus ensure the security of data transmission.
[0154] In one embodiment, such as Figure 7 As shown, a file receiving method is provided, which can be applied to... Figure 1 Taking the receiving end as an example, the explanation includes the following steps:
[0155] Step 702: Receive multiple transmission messages sequentially.
[0156] Optionally, since the sending end is based on the HTTP protocol and transmits the corresponding transmission messages of each encoded array to the receiving end in the order in which the original arrays are read from the data input stream, the receiving end also responds to the HTTP message requests in the order in which the original arrays are read and receives multiple transmission messages in sequence.
[0157] Step 704: For each transmission message, determine the sub-output stream corresponding to the transmission message, the encryption array output by the sub-output stream, and the encryption key of the encryption array.
[0158] Optionally, for each transmitted message, the receiving end can parse the message body of the transmitted message, determine the sub-output stream corresponding to the transmitted message, and identify the encrypted array output by the sub-output stream. The receiving end can also obtain the encryption key of the encrypted array by parsing the message header of the transmitted message.
[0159] Step 706: Decrypt the encrypted array based on the encryption key to obtain the encoded array.
[0160] Optionally, for each transmitted message, since the sending end encrypts each encoded array based on the encryption key to obtain the encrypted array, the sending end further assembles the transmitted message based on the encryption key and the encrypted array, ensuring that the encryption key and encrypted array corresponding to each transmitted message are both configured within the transmitted message. Therefore, for each transmitted message, the receiving end can parse the encryption key corresponding to the transmitted message from the transmitted message, and then decrypt the encrypted array corresponding to the transmitted message based on the encryption key to obtain the encoded array corresponding to the transmitted message.
[0161] Step 708: Decode the encoded array to obtain the original array corresponding to the transmitted message.
[0162] The encoding algorithm can be flexibly configured according to the actual application scenario.
[0163] Optionally, if the sending end uses only one encoding algorithm to encode each original array separately to obtain the corresponding encoded array for each original array, the receiving end can use a decoding algorithm corresponding to the encoding algorithm used by the sending end to decode the encoded array corresponding to each transmitted message separately to obtain the original array corresponding to each transmitted message.
[0164] For example, taking the example of the sending end encoding each original array based on the Base64 encoding algorithm, the receiving end can decode the encoding array corresponding to each transmitted message based on the Base64 decoding algorithm corresponding to the Base64 encoding algorithm to obtain the original array corresponding to each transmitted message.
[0165] Optionally, when the sending end uses multiple encoding algorithms to encode each original array separately, for each transmitted message, during the process of encoding the original array at the sending end to obtain the encoded array, the sending end can record the encoding method of the encoded array corresponding to each transmitted message and send the recorded encoding method to the receiving end, so that the receiving end can decode the encoded array corresponding to each transmitted message based on the encoding method corresponding to each transmitted message to obtain the original array corresponding to each transmitted message.
[0166] For example, the sending end encodes the i-th original array based on Base64 encoding to obtain the i-th encoded array, and encodes the j-th original array based on ASCII encoding to obtain the j-th encoded array. The receiving end can decode the i-th encoded array based on Base64 decoding according to the encoding method recorded by the sending end to obtain the i-th original array. The receiving end can also decode the j-th encoded array based on ASCII decoding to obtain the j-th original array.
[0167] Step 710: Determine the file that matches the original array corresponding to each of the multiple transmission messages.
[0168] At the sending end, there is a one-to-one correspondence between the original array, the encoded array, the encrypted array, and the transmitted message; at the receiving end, there is also a one-to-one correspondence between the transmitted message, the encrypted array, the encoded array, and the original array.
[0169] Optionally, since the sending end converts the file into a data input stream and reads the original array from the data input stream in a loop, it sends each transmission message to the receiving end sequentially according to the order in which the original arrays were read. Therefore, the receiving end can determine the order of the original arrays corresponding to each transmission message based on the order in which the transmission messages are received, and then perform the reverse process of reading each original array in a loop according to the determined order to obtain a data output stream, and convert the data input stream into a file. That is, the receiving end can adopt the reverse process corresponding to the file transfer method of the sending end to obtain the file.
[0170] In this embodiment, each transmitted message is parsed, and the parsed encrypted array is decrypted and decoded to obtain the original array corresponding to the transmitted message. The file is then reconstructed based on the original arrays corresponding to each of the multiple transmitted messages. On one hand, during file reception, especially for the transmission of very large files, there is no need to spend excessive time caching the file, nor is the file directly processed. Instead, binary arrays are transmitted and processed, ensuring that the file reception process does not consume a large amount of memory and improving file reception efficiency. On the other hand, the steps of parsing the transmitted messages and decrypting before decoding enhance the security of the file reception process. Therefore, both the security and efficiency of the file reception process are ensured.
[0171] In one embodiment, such as Figure 8 As shown, determining the sub-output stream corresponding to the transmitted message, the encrypted array output by the sub-output stream, and the encryption key of the encrypted array includes:
[0172] Step 802: Decompose the transmitted message to determine the sub-output stream corresponding to the transmitted message, the encryption array output by the sub-output stream, and the key information.
[0173] Optionally, for each transmitted message, the receiving end can split the transmitted message to determine the message body, message header, and header length corresponding to the transmitted message, thereby determining the sub-output stream corresponding to the transmitted message, the encryption array output by the sub-output stream, and the key information.
[0174] Step 804: Decrypt the key information to obtain the encryption key for the encryption array.
[0175] Optionally, the receiving end can obtain the CA certificate issued by the key management end, retrieve the receiving end's private key from the CA certificate, and then decrypt the key information based on the receiving end's private key to obtain the encryption key of the encryption array.
[0176] For example, if the sending end encrypts the encryption key corresponding to each encoding array based on a receiving end public key to obtain the key information of the encryption key corresponding to each encoding array, then for each transmitted message, the receiving end can decrypt the key information corresponding to each transmitted message based on the receiving end private key corresponding to the receiving end public key to obtain the encryption key corresponding to each transmitted message.
[0177] For example, when the sending end encrypts the encryption keys corresponding to each encoding array based on multiple receiving end public keys, for each encoding array, the sending end can record the CA certificate to which the receiving end public key belongs during the encryption process, and send the recorded information related to the receiving end public key to the receiving end. Therefore, for the key information in each transmitted message, the receiving end can determine the receiving end private key required for decrypting the key information by identifying the CA certificate to which the receiving end public key belongs during the acquisition of the key information. Based on the determined receiving end private key, the receiving end can decrypt the key information to obtain the encryption key corresponding to the transmitted message, and then decrypt the encryption array corresponding to the transmitted message based on the encryption key to obtain the encoding array corresponding to the transmitted message.
[0178] In this embodiment, the key information is decrypted using the receiver's private key to obtain the encryption key. This improves the security of the encryption key during file reception, thereby enhancing the security of the encoded array obtained based on the encryption key and ensuring the security of data transmission.
[0179] In one embodiment, such as Figure 9As shown, the transmitted message is split to determine the corresponding sub-output stream, the encryption array output by the sub-output stream, and the key information, including:
[0180] Step 902: Parse the transmitted message to obtain the message body and message header.
[0181] Optionally, for each transmitted message, the receiving end can parse the transmitted message to obtain the message body and message header of the transmitted message, and identify the message header to determine the header length of the message header.
[0182] Step 904: Based on the message body and the header length of the message header, obtain the encrypted array output by the sub-input stream and the sub-output stream corresponding to the transmitted message.
[0183] Optionally, for each transmitted message, the receiving end can convert the message body into a sub-input stream corresponding to the transmitted message, and read an encrypted array from the sub-input stream with a length consistent with the header length of the message header.
[0184] Step 906: Obtain the key information corresponding to the transmitted message based on the message header.
[0185] Optionally, for each transmitted message, the receiving end can parse the content in the message header to obtain the key information corresponding to the transmitted message from the message header.
[0186] In this embodiment, by splitting and parsing the transmitted message, the corresponding encryption array and key information are obtained. This allows the encryption key extracted from the key information to decrypt the encryption array, thereby performing the decryption-decoding step. This helps ensure the security of the transmitted message and thus the security of the data transmission.
[0187] In one embodiment, such as Figure 10 As shown, this provides a method for use in insecure network environments. Figure 1 The flowchart of the sending and receiving ends, combining the above file transfer and file receiving methods, mainly includes the following processes:
[0188] For the sending end, the sending end can first convert the file into a data input stream, read multiple raw arrays corresponding to the file from the data input stream, and encode each raw array separately to obtain the encoded array corresponding to each raw array. Then, for each encoded array, the sending end can obtain a randomly generated encryption key, and encrypt the encoded array based on the encryption key to obtain an encrypted array, and determine the sub-output stream that outputs the encrypted array.
[0189] Furthermore, the sending end can obtain the receiving end's public key from the key management end, and encrypt the encryption key based on the receiving end's public key to obtain the key information corresponding to the encryption key. Then, the sending end can use the sub-output stream corresponding to the encoded array as the message body of the transmission message corresponding to the encoded array, and determine the header length of the transmission message corresponding to the encoded array based on the length of the encryption array corresponding to the sub-output stream. According to the header length, the key information is configured as the message header of the transmission message corresponding to the encoded array. Thus, based on the message body and message header, the transmission message corresponding to the encoded array is generated, and then the transmission messages corresponding to each encoded array are transmitted to the receiving end in sequence.
[0190] For the receiving end, it can sequentially receive multiple transmission messages. For each transmission message, it parses and processes the message to obtain the message body and message header. Based on the message body and the header length, it obtains the corresponding sub-input stream and the encrypted array output by the sub-output stream. Based on the message header, it obtains the key information corresponding to the transmission message, decrypts the key information to obtain the encryption key for the encrypted array, and then decrypts the encrypted array based on the encryption key to obtain the encoded array. The encoded array is then decoded to obtain the original array corresponding to the transmission message. Finally, it identifies the files that match the original arrays corresponding to the multiple transmission messages and assembles the files that match the original arrays corresponding to the multiple transmission messages to obtain the original file.
[0191] In this embodiment, on the one hand, during file transfer and file reception, there is no need to spend excessive time caching files or directly process them. Instead, the file is converted and split into arrays for processing, and then the processed arrays are converted into output streams and assembled into transmission messages. These messages are then transmitted sequentially, reducing memory usage and improving transmission efficiency. On the other hand, by combining the steps of encoding, encryption, assembling transmission messages, parsing transmission messages, decryption, and decoding, the security of data transmission is greatly improved. Therefore, in application scenarios involving the transmission of extremely large files, this embodiment can meet the transmission requirements for such large files, ensuring both security and efficiency during transmission.
[0192] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0193] Based on the same inventive concept, this application also provides a file transfer apparatus for implementing the file transfer method described above. The solution provided by this apparatus is similar to the implementation scheme described in the file transfer method above; therefore, the specific limitations in one or more file transfer apparatus embodiments provided below can be found in the limitations of the file transfer method described above, and will not be repeated here.
[0194] In one embodiment, such as Figure 11 As shown, a file transfer device 1100 is provided, including: a file conversion module 1102, an array encoding module 1104, an array encryption module 1106, a message determination module 1108, and a message transmission module 1110, wherein:
[0195] The file conversion module is used to convert a file into a data input stream and read multiple raw arrays corresponding to the file from the data input stream;
[0196] The array encoding module is used to encode each original array separately to obtain the corresponding encoded array for each original array.
[0197] The array encryption module is used to encrypt the encoded array for each encoded array to obtain an encrypted array, and to determine the sub-output stream of the encrypted array.
[0198] The message determination module is used to determine the transmission message corresponding to the encoded array based on the sub-output stream and the encryption key used in the encryption process.
[0199] The message transmission module is used to transmit the transmission messages corresponding to each encoded array in sequence.
[0200] In the aforementioned file transfer device, the file is converted into a data input stream. Multiple raw arrays corresponding to the file are read from the data input stream, essentially converting and splitting the file into arrays. This eliminates the need for file caching during subsequent transmission, minimizing memory consumption. Each raw array is then encoded to obtain its corresponding encoded array. Each encoded array is then encrypted to obtain an encrypted array. This prior encoding and encryption of the raw arrays enhances transmission security. A sub-output stream for the encrypted array is then determined. Based on the sub-output stream and the encryption key used in the encryption process, the corresponding transmission message for each encoded array is determined, and these messages are transmitted sequentially. On one hand, in scenarios involving the transmission of extremely large files, there is no need to cache or directly process them. Instead, the large file is converted and split into arrays for processing, and then the processed arrays are converted into output streams and assembled into transmission messages. This sequential transmission reduces memory usage and improves transmission efficiency. On the other hand, the prior encoding and encryption, along with the message assembly steps, further enhance transmission security. Therefore, the entire process can meet the transmission needs of extremely large files, ensuring both the security of the transmission process and improving transmission efficiency.
[0201] In one embodiment, the array encryption module is also used to obtain a randomly generated encryption key; and to encrypt the encoded array based on the encryption key to obtain an encrypted array.
[0202] In one embodiment, the message determination module is further configured to: obtain the encryption key used in the encryption process, determine the key information corresponding to the encryption key; and assemble the sub-output stream and the key information to obtain the transmission message corresponding to the encoded array.
[0203] In one embodiment, the file transfer device further includes: a key information acquisition module, used to acquire the public key of the receiving end; and based on the public key of the receiving end, to encrypt the encryption key to obtain the key information corresponding to the encryption key.
[0204] In one embodiment, the file transfer device further includes: a message generation module, configured to use the sub-output stream corresponding to the encoded array as the message body of the transmission message corresponding to the encoded array; determine the header length of the transmission message corresponding to the encoded array based on the length of the encryption array corresponding to the sub-output stream; configure the key information as the message header of the transmission message corresponding to the encoded array according to the header length; and generate the transmission message corresponding to the encoded array based on the message body and the message header.
[0205] Each module in the aforementioned file transfer device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0206] Based on the same inventive concept, this application also provides a file receiving apparatus for implementing the file receiving method described above. The solution provided by this apparatus is similar to the implementation scheme described in the file receiving method above. Therefore, the specific limitations in one or more file receiving apparatus embodiments provided below can be found in the limitations of the file receiving method described above, and will not be repeated here.
[0207] In one embodiment, such as Figure 12 As shown, a file receiving device 1200 is provided, including: a message receiving module 1202, a message splitting module 1204, an array decryption module 1206, an array decoding module 1208, and a file determination module 1210, wherein:
[0208] The message receiving module is used to receive multiple transmitted messages sequentially;
[0209] The message splitting module is used to determine, for each transmitted message, the corresponding sub-output stream, the encrypted array output by the sub-output stream, and the encryption key of the encrypted array.
[0210] The array decryption module is used to decrypt the encrypted array based on the encryption key to obtain the encoded array;
[0211] The array decoding module is used to decode the encoded array to obtain the original array corresponding to the transmitted message;
[0212] The file determination module is used to determine the file that matches the original array corresponding to each of the multiple transmission messages.
[0213] In one embodiment, the message splitting module is further configured to: split the transmitted message into sub-output streams corresponding to the transmitted message, determine the encrypted array output by the sub-output streams, and the key information; and decrypt the key information to obtain the encryption key of the encrypted array.
[0214] In one embodiment, the file receiving device further includes: a message parsing module, used to parse the transmitted message to obtain the message body and message header of the transmitted message; based on the message body and the header length of the message header, to obtain the sub-input stream corresponding to the transmitted message and the encrypted array output by the sub-output stream; and based on the message header, to obtain the key information corresponding to the transmitted message.
[0215] Each module in the aforementioned file receiving device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0216] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 13 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores file transfer data or file reception data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the aforementioned file transfer or file reception methods.
[0217] Those skilled in the art will understand that Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0218] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0219] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0220] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0221] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0222] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0223] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A file transfer method, characterized in that, The method includes: Convert the file into a data input stream, and read multiple raw arrays corresponding to the file from the data input stream; Each of the original arrays is encoded to obtain the corresponding encoded array for each original array. For each of the encoded arrays, the encoded arrays are encrypted to obtain an encrypted array, and a sub-output stream for outputting the encrypted array is determined; Based on the sub-output stream and the encryption key used in the encryption process, determine the transmission message corresponding to the encoded array; The transmission messages corresponding to each of the original arrays are transmitted sequentially according to the order in which they are read from the data input stream; The step of determining the transmission message corresponding to the encoded array based on the sub-output stream and the encryption key used in the encryption process includes: Obtain the encryption key used in the encryption process and determine the key information corresponding to the encryption key; The sub-output stream corresponding to the encoded array is used as the message body of the transmission message corresponding to the encoded array; Based on the length of the encrypted array corresponding to the sub-output stream, determine the header length of the transmission message corresponding to the encoded array; Configure the key information as the message header of the transmission message corresponding to the encoded array according to the header length; Based on the message body and the message header, a transmission message corresponding to the encoded array is generated.
2. The method according to claim 1, characterized in that, The step of encrypting the encoded array to obtain the encrypted array includes: Obtain the randomly generated encryption key; The encoded array is encrypted using the encryption key to obtain an encrypted array.
3. The method according to claim 1, characterized in that, The step of converting the file into a data input stream and reading multiple raw arrays corresponding to the file from the data input stream includes: The input bytes are obtained from the file to be transmitted. Based on the obtained input bytes, a data input stream is generated. The data input stream is a byte input stream. According to the data arrangement order in the data input stream, a raw array of a preset length is read sequentially from the data input stream to obtain multiple raw arrays corresponding to the file.
4. The method according to claim 1, characterized in that, The step of determining the key information corresponding to the encryption key includes: Obtain the receiver's public key; Based on the public key of the receiving end, the encryption key is encrypted to obtain the key information corresponding to the encryption key.
5. The method according to any one of claims 1 to 4, characterized in that, Both the original array and the encoded array are byte arrays.
6. A file receiving method, characterized in that, The method includes: Receive multiple transmission messages sequentially; For each of the transmitted messages, determine the sub-output stream corresponding to the transmitted message, the encryption array output by the sub-output stream, and the encryption key of the encryption array; The encrypted array is decrypted based on the encryption key to obtain the encoded array; The encoded array is decoded to obtain the original array corresponding to the transmitted message; Based on the order in which each transmission message is received, the order of the original arrays corresponding to each transmission message is determined, and the reverse process of cyclically reading each original array is performed according to the determined order to obtain a data output stream, and to determine the file that matches the original arrays corresponding to each of the multiple transmission messages. The step of determining the sub-output stream corresponding to the transmitted message, the encrypted array output by the sub-output stream, and the encryption key of the encrypted array includes: The transmitted message is parsed to obtain the message body and message header of the transmitted message; Based on the message body and the header length of the message header, obtain the sub-input stream corresponding to the transmitted message and the encrypted array output by the sub-output stream; Based on the message header, the key information corresponding to the transmitted message is obtained; The key information is decrypted to obtain the encryption key for the encryption array.
7. The method according to claim 6, characterized in that, The method further includes: Based on the encoding method corresponding to each transmitted message, the encoding array corresponding to each transmitted message is decoded to obtain the original array corresponding to each transmitted message.
8. The method according to claim 6, characterized in that, The method further includes: For each key information in the transmitted message, by determining the CA certificate to which the public key of the receiving end belongs during the process of obtaining the key information, the private key of the receiving end required for decryption of the key information is determined, and the key information is decrypted based on the determined private key of the receiving end to obtain the encryption key corresponding to the transmitted message.
9. A file transfer device, characterized in that, The device includes: The file conversion module is used to convert a file into a data input stream and read multiple raw arrays corresponding to the file from the data input stream; An array encoding module is used to encode each of the original arrays separately to obtain the encoded arrays corresponding to each of the original arrays. An array encryption module is used to encrypt each of the encoded arrays to obtain an encrypted array, and to determine a sub-output stream that outputs the encrypted array; The message determination module is used to determine the transmission message corresponding to the encoded array based on the sub-output stream and the encryption key used in the encryption process; The message transmission module is used to sequentially transmit the transmission messages corresponding to each of the encoded arrays. The message determination module is also used to: obtain the encryption key used in the encryption process, and determine the key information corresponding to the encryption key; The message generation module is used to take the sub-output stream corresponding to the encoding array as the message body of the transmission message corresponding to the encoding array; determine the header length of the transmission message corresponding to the encoding array based on the length of the encryption array corresponding to the sub-output stream; configure the key information as the message header of the transmission message corresponding to the encoding array according to the header length; and generate the transmission message corresponding to the encoding array based on the message body and the message header.
10. The apparatus according to claim 9, characterized in that, The array encryption module is also used to obtain a randomly generated encryption key; and to encrypt the encoded array based on the encryption key to obtain an encrypted array.
11. The apparatus according to claim 9, characterized in that, The file conversion module is used to obtain input bytes from the file to be transmitted, generate a data input stream based on the obtained input bytes, the data input stream being a byte input stream, and sequentially read a preset length of original array from the data input stream according to the data arrangement order in the data input stream to obtain multiple original arrays corresponding to the file.
12. The apparatus according to claim 11, characterized in that, The device further includes: The key information acquisition module is used to acquire the public key of the receiving end; based on the public key of the receiving end, the encryption key is encrypted to obtain the key information corresponding to the encryption key.
13. The apparatus according to claim 9, characterized in that, Both the original array and the encoded array are byte arrays.
14. A document receiving device, characterized in that, The device includes: The message receiving module is used to receive multiple transmitted messages sequentially; The message splitting module is used to determine, for each transmitted message, the corresponding sub-output stream, the encrypted array output by the sub-output stream, and the encryption key of the encrypted array; An array decryption module is used to decrypt the encrypted array based on the encryption key to obtain an encoded array; An array decoding module is used to decode the encoded array to obtain the original array corresponding to the transmitted message; The file determination module is used to determine the file that matches the original array corresponding to each of the multiple transmission messages; The message splitting module is further configured to: split the transmitted message to determine the sub-output stream corresponding to the transmitted message, the encryption array output by the sub-output stream, and the key information; and decrypt the key information to obtain the encryption key of the encryption array. The message parsing module is used to parse the transmitted message to obtain the message body and message header of the transmitted message; based on the message body and the header length of the message header, to obtain the sub-input stream corresponding to the transmitted message and the encrypted array output by the sub-output stream; and based on the message header, to obtain the key information corresponding to the transmitted message.
15. The apparatus according to claim 14, characterized in that, The array decoding module is used to decode the encoded array corresponding to each transmitted message based on the encoding method corresponding to each transmitted message, so as to obtain the original array corresponding to each transmitted message.
16. The apparatus according to claim 14, characterized in that, The message splitting module is further configured to: for the key information in each transmitted message, determine the CA certificate to which the public key of the receiving end belongs during the process of obtaining the key information, determine the private key of the receiving end required to decrypt the key information, and decrypt the key information based on the determined private key of the receiving end to obtain the encryption key corresponding to the transmitted message.
17. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.
18. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.
19. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.