A real-time encryption method and device based on network attached storage device
By creating socket pairs and encryption processing threads in the NAS device, real-time encryption processing and resource optimization are achieved, solving the encryption and decryption efficiency and security issues of traditional NAS devices in scenarios with large files or multi-threaded access, and improving the real-time performance and security of data storage.
Patent Information
- Application Number
- CN202511449540.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-11
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2045-10-11
AI Technical Summary
Traditional NAS devices suffer from poor real-time performance and insufficient security in data encryption, especially in scenarios involving large files or multi-threaded access. Existing AES encryption and decryption schemes struggle to balance high security and high efficiency.
By creating socket pairs and encryption processing threads in the NAS device, and binding the server-side socket to the encryption processing thread, real-time encryption processing of the data to be encrypted can be achieved. Furthermore, the encryption progress log file supports breakpoint resumption and optimized resource allocation, thereby improving the security and real-time performance of the encryption and decryption process.
It enables efficient, secure, and real-time AES encryption and decryption for NAS devices in scenarios involving large files or multi-threaded access, improving the security, real-time performance, and continuity of the encryption and decryption process while reducing network bandwidth consumption and data processing time.
Smart Images

Figure CN120934906B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of digital information technology, and particularly relates to a real-time encryption method and device based on a network attached storage device. BACKGROUND
[0002] With the development of information technology, the coordination of data confidentiality, integrity and availability in enterprise data storage and cloud services has become a core requirement of information security. NAS (Network Attached Storage) devices, as the core of enterprise data storage, are widely used for backup, sharing and remote access. However, traditional NAS devices have problems such as poor real-time performance and insufficient security in data encryption, making it difficult to adapt to massive data and complex network environments.
[0003] AES (Advanced Encryption Standard) algorithm has high encryption strength and efficiency, and is the preferred solution for NAS devices to implement data encryption. However, it faces multiple challenges in NAS deployment: AES encryption and decryption can slow down the I / O performance of NAS, and it is difficult to balance high security and high concurrency access. Existing software-based AES encryption solutions consume a large amount of CPU (Central Processing Unit) resources, and existing hardware-based AES encryption solutions only support fixed data block encryption, making it difficult to flexibly respond to file-level or streaming data encryption requirements.
[0004] Therefore, how to make up for the above shortcomings and achieve efficient, secure and real-time AES encryption and decryption for NAS devices is a problem that needs to be solved by people in the field. SUMMARY
[0005] The embodiments of the present application provide a real-time encryption method and device based on a network attached storage device, aiming to achieve efficient, secure and real-time AES encryption and decryption for NAS devices, especially for large files or multi-threaded access scenarios, to improve the security, real-time performance and continuity of the encryption and decryption process.
[0006] In a first aspect, the embodiments of the present application provide a real-time encryption method based on a network attached storage device, which comprises:
[0007] In the case of receiving an encryption request sent by a request end, a corresponding socket pair and an encryption processing thread are created based on the encryption request; wherein the socket pair includes a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol;
[0008] The server socket is bound to the encryption processing thread;
[0009] In the case that the to-be-encrypted data sent by the request end is received, the to-be-encrypted data is transmitted to the service end socket through the client socket, and the to-be-encrypted data is processed in real time by the encryption processing thread bound with the service end socket to obtain an encryption result.
[0010] Optionally, the method further comprises:
[0011] creating an encryption progress record file to determine a real-time encryption progress position;
[0012] storing the real-time encryption progress position in the encryption progress record file according to a preset period.
[0013] Optionally, after the real-time encryption progress position is stored in the encryption progress record file according to the preset period, the method further comprises:
[0014] in the case that the encryption interruption position request sent by the request end is received, determining an encryption interruption position based on the encryption progress record file;
[0015] sending the encryption interruption position to the request end to make the request end resend an encryption request and continue to transmit the to-be-encrypted data based on the encryption interruption position.
[0016] Optionally, after the encryption progress record file is created, the method further comprises:
[0017] generating interruption continuous transmission verification information based on the encryption progress record file and sending the interruption continuous transmission verification information to the request end;
[0018] Correspondingly, the encryption interruption position is determined based on the encryption progress record file, comprising:
[0019] in the case that the encryption interruption position request of the request end is received and the interruption continuous transmission verification information in the encryption interruption position request is verified, the encryption interruption position is determined based on the encryption progress record file.
[0020] Optionally, the interruption continuous transmission verification information is generated based on the encryption progress record file, comprising:
[0021] generating interruption continuous transmission verification information based on a universal unique identifier of the encryption request and file identification information and generation time information of the encryption progress record file.
[0022] Optionally, before the corresponding socket pair and the encryption processing thread are created based on the encryption request, the method further comprises:
[0023] determine a processing priority based on the encryption request, and determine preset resource allocation information based on the processing priority; wherein the preset resource allocation information comprises a central processing unit quota and an input / output bandwidth;
[0024] Correspondingly, the creating of the corresponding socket pair and the encryption processing thread based on the encryption request comprises:
[0025] creating the socket pair based on the input / output bandwidth, and creating the encryption processing thread based on the central processing unit quota;
[0026] Correspondingly, the transmitting of the data to be encrypted to the server socket through the client socket, and the real-time encryption processing of the data to be encrypted by the encryption processing thread bound to the server socket to obtain an encryption result comprises:
[0027] obtaining current resource occupation information, and determining target resource allocation information corresponding to the encryption request based on the processing priority and the current resource occupation information in a case where the current resource occupation information is identified as being unable to meet the preset resource allocation information;
[0028] transmitting the data to be encrypted to the server socket through the client socket based on target input / output bandwidth in the target resource allocation information, and performing real-time encryption processing on the data to be encrypted by the encryption processing thread bound to the server socket based on target central processing unit quota in the target resource allocation information to obtain an encryption result.
[0029] Optionally, after the encryption result is obtained, the method further comprises:
[0030] in a case where a decryption request is received from the request end, creating a corresponding socket pair and a decryption processing thread based on the decryption request; wherein the socket pair comprises a server socket and a client socket;
[0031] binding the server socket to the decryption processing thread;
[0032] receiving, in real time, a decryption processing result of the decryption request corresponding to the decryption processing thread through the client socket and the server socket, and sending the decryption processing result to the request end in real time.
[0033] In a second aspect, an embodiment of the present application provides a real-time encryption device based on a network-attached storage device, the device comprising:
[0034] The creating module is configured to create a corresponding socket pair and an encryption processing thread based on the encryption request sent by the request end when receiving the encryption request; the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol;
[0035] The binding module is configured to bind the server socket and the encryption processing thread;
[0036] The encryption module is configured to transmit the to-be-encrypted data to the server socket through the client socket when receiving the to-be-encrypted data sent by the request end, and perform real-time encryption processing on the to-be-encrypted data through the encryption processing thread bound with the server socket to obtain an encryption result.
[0037] Optionally, the apparatus is further configured to:
[0038] create an encryption progress record file and determine a real-time encryption progress position;
[0039] store the real-time encryption progress position in the encryption progress record file according to a preset period.
[0040] Optionally, the apparatus is further configured to:
[0041] determine an encryption interruption position based on the encryption progress record file when receiving an encryption interruption position request sent by the request end;
[0042] send the encryption interruption position to the request end, so that the request end re-sends an encryption request and continues to transmit the to-be-encrypted data based on the encryption interruption position.
[0043] Optionally, the apparatus is further configured to:
[0044] generate interruption continuous transmission verification information based on the encryption progress record file and send the interruption continuous transmission verification information to the request end;
[0045] Correspondingly, the determining of the encryption interruption position based on the encryption progress record file comprises:
[0046] determining the encryption interruption position based on the encryption progress record file when receiving the encryption interruption position request sent by the request end and verifying the interruption continuous transmission verification information in the encryption interruption position request.
[0047] Optionally, the apparatus is further configured to:
[0048] Generate the interrupting continuous transmission verification information based on the universally unique identifier of the encryption request and the file identification information and the generation time information of the encryption progress record file.
[0049] Optionally, the apparatus is further configured to:
[0050] Determine a processing priority based on the encryption request, and determine preset resource allocation information based on the processing priority; wherein the preset resource allocation information comprises a central processing unit quota and an input / output bandwidth;
[0051] Correspondingly, the creating module is specifically configured to:
[0052] In a case where the encryption request sent by the request end is received, create a socket pair based on the input / output bandwidth, and create an encryption processing thread based on the central processing unit quota; wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol;
[0053] Correspondingly, the encryption module is specifically configured to:
[0054] Obtain current resource occupation information, and in a case where it is identified that the current resource occupation information cannot meet the preset resource allocation information, determine target resource allocation information corresponding to the encryption request based on the processing priority and the current resource occupation information;
[0055] Based on a target input / output bandwidth in the target resource allocation information, transmit the data to be encrypted to the server socket through the client socket, and perform real-time encryption processing on the data to be encrypted based on a target central processing unit quota in the target resource allocation information through the encryption processing thread bound to the server socket, to obtain an encryption result.
[0056] Optionally, the apparatus is further configured to:
[0057] In a case where the decryption request sent by the request end is received, create a corresponding socket pair and a decryption processing thread based on the decryption request; wherein the socket pair comprises a server socket and a client socket;
[0058] Bind the server socket to the decryption processing thread;
[0059] Real-time receive a decryption processing result of the decryption request corresponding to the encryption data by the decryption processing thread through the client socket and the server socket, and real-time send the decryption processing result to the request end.
[0060] In a third aspect, an electronic device is provided, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, and the program or instructions, when executed by the processor, implement the method of the first aspect.
[0061] In a fourth aspect, a readable storage medium is provided, which stores a program or instructions, and the program or instructions, when executed by a processor, implement the method of the first aspect.
[0062] In the embodiments of the present application, in the case that an encryption request sent by a request end is received, a corresponding socket pair and an encryption processing thread are created based on the encryption request; the socket pair includes a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol; the server socket is bound to the encryption processing thread; in the case that encrypted data sent by the request end is received, the encrypted data is transmitted to the server socket through the client socket, and the encrypted data is processed in real time by the encryption processing thread bound to the server socket to obtain an encryption result. The above real-time encryption method based on a network attached storage device realizes efficient, safe and real-time AES encryption and decryption of the NAS device, and especially for large file or multi-thread access scenarios, the safety, real-time performance and continuity of the encryption and decryption process are improved. BRIEF DESCRIPTION OF DRAWINGS
[0063] Figure 1 is a flowchart of a real-time encryption method based on a network attached storage device provided by the embodiments of the present application;
[0064] Figure 2 is a system architecture diagram of a real-time encryption processing process provided by the embodiments of the present application;
[0065] Figure 3 is a flowchart of another real-time encryption method based on a network attached storage device provided by the embodiments of the present application;
[0066] Figure 4 is a flowchart of another real-time encryption method based on a network attached storage device provided by the embodiments of the present application;
[0067] Figure 5 is a flowchart of another real-time encryption method based on a network attached storage device provided by the embodiments of the present application;
[0068] Figure 6 is a system architecture diagram of a real-time decryption processing process provided by the embodiments of the present application;
[0069] Figure 7 is a structural schematic diagram of a real-time encryption device based on a network-attached storage device provided by an embodiment of the present application.
[0070] Figure 8 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0071] In order to make the objects, technical solutions and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in combination with the drawings. It can be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the convenience of description, only parts related to the present application are shown in the drawings, but not all contents. Before discussing the example embodiments in more detail, it should be mentioned that some example embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The processes can be terminated when the operations are completed, but can also have additional steps not included in the drawings. The processes can correspond to methods, functions, procedures, subroutines, subprograms, etc.
[0072] The technical solutions in the embodiments of the present application will be described clearly in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art belong to the scope of protection of the present application.
[0073] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally a category, and do not limit the number of objects, for example, the first object can be one or more. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / ", generally means that the front and rear associated objects are in a "or" relationship.
[0074] The real-time encryption method and device based on a network-attached storage device provided by the embodiments of the present application will be described in detail below in combination with the drawings and specific embodiments and their application scenarios.
[0075] Firstly, the present application is applicable to the scenario of data storage based on a network-attached storage device. Based on the above use scenario, it can be understood that the execution subject of the present application can be a main thread of the network-attached storage device. Specifically, the creation of a socket and an encryption processing thread and the transmission of to-be-encrypted data can be performed by the main thread, realizing real-time reception and encryption of to-be-encrypted data.
[0076] Among them, the network-attached storage device can be a special file storage device connected to the network and providing file-level data storage services.
[0077] Among them, the main thread can be a main thread process responsible for overall coordination of various core tasks in the network-attached storage device, and is the main control flow of the network-attached storage device. In the present scheme, the main thread is specifically a thread dedicated to processing requests sent by the request end.
[0078] Among them, the request end can be a terminal device or an application program in the network that needs to send data storage, encryption, decryption and other requests to the network-attached storage device, such as a personal computer, a mobile terminal, a server application and an Internet of Things device, etc., which establishes a connection with the network-attached storage device and interacts through a network communication protocol.
[0079] Figure 1 is a flowchart of a real-time encryption method based on a network-attached storage device provided by an embodiment of the present application. As shown in Figure 1 , specifically comprising the following steps:
[0080] S101, in the case of receiving an encryption request sent by the request end, creating a corresponding socket pair and an encryption processing thread based on the encryption request; wherein the socket pair includes a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol.
[0081] Among them, the encryption request can be an instruction message sent by the request end to the network-attached storage device, requiring encryption processing of specific data.
[0082] In one embodiment, the way of receiving the encryption request sent by the request end can use the network communication protocol between the request end and the network-attached storage device to realize the sending of the encryption request by the request end and the receiving of the encryption request by the main thread.
[0083] Among them, the socket pair can be a pair of associated socket instances created inside the same network-attached storage device for inter-process or inter-thread communication, including a server socket and a client socket. Among them, the socket can be a network programming interface used to realize communication between different hosts or different processes in the same host, supporting data sending and receiving operations.
[0084] Specifically, for the encryption request, the server socket can be a socket in a socket pair that is mainly in a listening state and used to receive a data transmission request; the client socket can be a socket in the socket pair that is mainly used to initiate a connection and transmit data. The server socket and the client socket belong to the same transmission control protocol. The transmission control protocol (TCP) can be a connection-oriented, reliable, and byte stream-based transport layer communication protocol that can guarantee the order and integrity of data transmission.
[0085] In an embodiment, the manner of creating the corresponding socket pair based on the encryption request can use a socket programming interface (for example, the socket() function) to create based on the encryption request.
[0086] The encryption processing thread can be a sub-thread specially used for performing data encryption operations, dynamically created by the main thread according to the encryption request, having an independent execution path, and capable of using a preset encryption algorithm to perform encryption processing on received data to be encrypted without affecting the normal operation of the main thread.
[0087] In an embodiment, the manner of creating the corresponding encryption processing thread based on the encryption request can use a multi-thread programming technology (for example, the pthread_create() function) to create, initialize the execution environment of the encryption processing thread based on the encryption parameters specified in the encryption request (including encryption algorithm configuration, key loading, etc.), set the thread state to start after creation, and wait to receive data to be encrypted.
[0088] S102, bind the server socket to the encryption processing thread.
[0089] In an embodiment, the manner of binding the server socket to the encryption processing thread can use a mapping relationship table to store the identification of the server socket and the identification of the encryption processing thread in association.
[0090] S103, in the case of receiving the data to be encrypted sent by the request end, transmitting the data to be encrypted to the server socket through the client socket, and performing real-time encryption processing on the data to be encrypted through the encryption processing thread bound to the server socket to obtain an encryption result.
[0091] The data to be encrypted can be original data required by the request end to be stored in the network attached storage device, including but not limited to document files, image data, video clips, database records, etc. These data need to be encrypted before storage to ensure security.
[0092] In one embodiment, the manner in which the request end sends the data to be encrypted can be achieved by using a network communication protocol between the request end and the network attached storage device to enable the request end to send the data to be encrypted and the main thread to receive the data to be encrypted.
[0093] In one embodiment, the manner in which the client socket transmits the data to be encrypted to the server socket can be achieved by using the client socket to encapsulate the received data to be encrypted according to the TCP protocol specification, and sending it to the server socket through an internal communication channel. The server socket decapsulates the received data after receiving the data, and restores it to the original data to be encrypted.
[0094] In one embodiment, the manner in which the encryption processing thread bound to the server socket performs real-time encryption processing on the data to be encrypted to obtain the encryption result can be achieved by using the above mapping relationship table to trigger the corresponding encryption processing thread to read the data to be encrypted from the server socket when the server socket receives the data to be encrypted, and using a preset encryption algorithm to process the received data to be encrypted. In this scheme, the preset encryption algorithm can be an AES (Advanced Encryption Standard) algorithm.
[0095] The encryption result can be data that has been encrypted and stored securely in the network attached storage device in the form of a file.
[0096] Figure 2 is a system architecture diagram of the real-time encryption processing process provided by the embodiments of the present application. As shown in Figure 2 The request end transmits the data to be encrypted to the main thread of the network attached storage device in real time. The main thread transmits the data to be encrypted to the server socket in real time through the client socket, so that the encryption processing thread bound to the server socket can receive the data to be encrypted in real time, and perform real-time encryption processing on the real-time received data to be encrypted.
[0097] In the embodiment of the present application, in the case that the encryption request sent by the request end is received, a corresponding socket pair and an encryption processing thread are created based on the encryption request; the socket pair includes a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol; the server socket is bound with the encryption processing thread; in the case that the to-be-encrypted data sent by the request end is received, the to-be-encrypted data is transmitted to the server socket through the client socket, and the to-be-encrypted data is processed in real time by the encryption processing thread bound with the server socket to obtain an encryption result. The real-time encryption method based on the network attached storage device realizes efficient, safe and real-time AES encryption and decryption of the NAS device, and especially for large files or multi-thread access scenarios, the safety, real-time performance and continuity of the encryption and decryption process are improved.
[0098] Figure 3 is a flowchart of another real-time encryption method based on a network attached storage device provided by the embodiment of the present application. As shown in Figure 3 , the method specifically includes the following steps:
[0099] S301, in the case that the encryption request sent by the request end is received, a corresponding socket pair and an encryption processing thread are created based on the encryption request; the socket pair includes a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol.
[0100] S302, the server socket is bound with the encryption processing thread.
[0101] S303, in the case that the to-be-encrypted data sent by the request end is received, the to-be-encrypted data is transmitted to the server socket through the client socket, and the to-be-encrypted data is processed in real time by the encryption processing thread bound with the server socket to obtain an encryption result.
[0102] S304, an encryption progress record file is created to determine a real-time encryption progress position.
[0103] The encryption progress record file can be a file used for recording the encryption processing progress of the to-be-encrypted data in real time, and can be stored in a temporary storage area of the network attached storage device.
[0104] In an embodiment, the method of creating the encryption progress record file can generate a file named by a unique encryption task identifier in a specified directory by a main thread when the encryption processing thread is started, and initialize the file content.
[0105] The real-time encryption progress position can be a specific position of data that has been encrypted by the current encryption processing thread in the entire data to be encrypted. In the present scheme, the real-time encryption progress position can specifically refer to an offset value, i.e., the number of bytes between the starting position of the data to be encrypted and the ending position of the encrypted part.
[0106] In one embodiment, the manner of determining the real-time encryption progress position can adopt the following manner: after completing the encryption of a piece of data, the encryption processing thread updates the offset value in real time according to the number of processed bytes, and synchronizes the value to the main thread.
[0107] S305, according to a preset period, storing the real-time encryption progress position in the encryption progress record file.
[0108] The preset period can refer to a time interval that is preset for periodically storing the real-time encryption progress position.
[0109] In one embodiment, the manner of storing the real-time encryption progress position in the encryption progress record file according to the preset period can adopt the following manner: setting a timer, and triggering the writing operation of the real-time encryption progress position once every preset period.
[0110] It can be understood that the step of "determining the real-time encryption progress position, and storing the real-time encryption progress position in the encryption progress record file according to a preset period" is executed synchronously with S303.
[0111] Optionally, when it is identified that the encryption processing of the data to be encrypted is completed, the encryption progress record file can be deleted.
[0112] Optionally, after the real-time encryption progress position is stored in the encryption progress record file according to the preset period, the method further includes:
[0113] In the case that the encryption interruption position request sent by the request end is received, determining the encryption interruption position based on the encryption progress record file;
[0114] Sending the encryption interruption position to the request end, so that the request end re-sends the encryption request and continues to transmit the data to be encrypted based on the encryption interruption position.
[0115] The encryption interruption position request can be a request message for querying the encryption interruption position sent by the request end to the main thread of the network-attached storage device after the encryption process is interrupted. The encryption interruption position can be the real-time encryption progress position when the encryption process is interrupted.
[0116] In one embodiment, the manner of receiving the encryption interrupt position request sent by the request end can be achieved by using a network communication protocol between the request end and the network attached storage device to realize the sending of the encryption interrupt position request by the request end and the receiving of the encryption interrupt position request by the main thread.
[0117] In one embodiment, the manner of determining the encryption interrupt position based on the encryption progress record file can be achieved by searching for the corresponding encryption progress record file according to the encryption task identifier carried in the encryption interrupt position request after the main thread receives the encryption interrupt position request, and reading the latest real-time encryption progress position stored in the encryption progress record file as the encryption interrupt position.
[0118] In one embodiment, the manner of determining the encryption interrupt position based on the encryption progress record file can be achieved by searching for the corresponding encryption progress record file according to the encryption task identifier carried in the encryption interrupt position request after the main thread receives the encryption interrupt position request, and reading the latest real-time encryption progress position stored in the encryption progress record file as the encryption interrupt position.
[0119] In one embodiment, the manner of determining the encryption interrupt position based on the encryption progress record file can be achieved by searching for the corresponding encryption progress record file according to the encryption task identifier carried in the encryption interrupt position request after the main thread receives the encryption interrupt position request, and reading the latest real-time encryption progress position stored in the encryption progress record file as the encryption interrupt position.
[0120] Optionally, after the encryption progress record file is created, the method further includes:
[0121] generating interrupt resume verification information based on the encryption progress record file, and sending the interrupt resume verification information to the request end;
[0122] Correspondingly, the determining of the encryption interrupt position based on the encryption progress record file includes:
[0123] determining the encryption interrupt position based on the encryption progress record file in a case where the encryption interrupt position request of the request end is received and the interrupt resume verification information in the encryption interrupt position request is verified.
[0124] The interrupt resume verification information can be used to uniquely identify the resume authority of the encryption task, and has timeliness and uniqueness.
[0125] In one embodiment, the manner of generating the interrupt resume verification information based on the encryption progress record file can be achieved by performing a hash operation on the metadata of the encryption progress record file, and combining a time factor randomly generated to generate an encrypted string as the interrupt resume verification information.
[0126] Optionally, the generating of the interrupt resume verification information based on the encryption progress record file includes:
[0127] generate the interrupting resume verification information based on the universally unique identifier of the encryption request and the file identification information and the generation time information of the encryption progress record file.
[0128] The universally unique identifier of the encryption request can be a globally unique string identifier (UUID, Universally Unique Identifier) allocated for each encryption request from the request end, which is usually dynamically generated by the main thread of the network-attached storage device when receiving the request, and is used to distinguish different encryption tasks and avoid confusion between tasks.
[0129] The file identification information of the encryption progress record file can be unique identification information of the encryption progress record file, such as a file name, an inode number of the file, or a file-specific hash code, which is used to accurately locate the corresponding encryption progress record file.
[0130] The generation time information of the encryption progress record file can be a specific timestamp when the encryption progress record file is created.
[0131] In one embodiment, the way of generating the interrupting resume verification information based on the universally unique identifier of the encryption request and the file identification information and the generation time information of the encryption progress record file can be to concatenate the universally unique identifier of the encryption request and the file identification information and the generation time information of the encryption progress record file into an original string in a predetermined format, and then use a predetermined hash algorithm to perform encryption operation on the original string to generate a fixed-length hash value, which is the interrupting resume verification information.
[0132] The advantage of this arrangement is that by generating the interrupting resume verification information based on the universally unique identifier of the encryption request and the file identification information and the generation time information of the encryption progress record file, the exclusive properties of the interrupting resume verification information can be ensured from three dimensions of task uniqueness, file association, and time effectiveness, making the interrupting resume verification information highly unique and unforgeable.
[0133] In one embodiment, the way of sending the interrupting resume verification information to the request end can be to use the network communication protocol between the request end and the network-attached storage device to realize the sending of the interrupting resume verification information by the main thread and the receiving of the interrupting resume verification information by the request end.
[0134] The verification of the interrupting resume verification information in the encryption interrupt position request can be that the main thread compares the interrupting resume verification information sent by the request end with the verification information of the corresponding encryption task stored locally, and confirms that they are consistent and have not exceeded the valid time limit, so as to determine that the verification is passed.
[0135] The advantage of the scheme is that, by generating the resume validation information based on the encryption progress record file and sending the resume validation information to the request end, and in the case that the encryption interrupt position request from the request end is received and the resume validation information in the encryption interrupt position request is verified, the encryption interrupt position is determined based on the encryption progress record file, unauthorized request ends can be effectively prevented from obtaining the encryption progress information or maliciously initiating a resume request, and the security of the resume process is enhanced.
[0136] The advantage of the scheme is that, by determining the encryption interrupt position based on the encryption progress record file in the case that the encryption interrupt position request from the request end is received, and sending the encryption interrupt position to the request end to make the request end resend the encryption request and resume the data to be encrypted based on the encryption interrupt position, the resume function of the encryption process can be implemented, repeated processing of the transmitted data due to interruption is avoided, and network bandwidth consumption and data processing time are significantly reduced.
[0137] The advantage of the scheme is that, by creating the encryption progress record file, determining the real-time encryption progress position, and storing the real-time encryption progress position in the encryption progress record file according to a preset period, the encryption progress can be quickly determined based on the encryption progress record file in the case of unexpected interruption of the encryption process.
[0138] Figure 4 is a flowchart of another real-time encryption method based on a network-attached storage device provided by an embodiment of the present application. As shown in Figure 4 , the specific steps include the following steps:
[0139] S401, in the case that an encryption request from a request end is received, determining a processing priority based on the encryption request, and determining preset resource allocation information based on the processing priority; wherein the preset resource allocation information includes a central processor quota and an input / output bandwidth.
[0140] The processing priority can be a task processing priority level set according to factors such as the urgency of the encryption request, the importance of the data, the permission level of the request end, etc.
[0141] In an embodiment, the way of determining the processing priority based on the encryption request can be to parse the priority identification field carried in the encryption request, or to determine comprehensively according to the preset priority level of the request end, or according to the data type of the data to be encrypted.
[0142] The preset resource allocation information can be a system resource allocation standard set in advance for different processing priorities to ensure the smooth execution of the encryption task, and the preset resource allocation information can include a central processor quota and an input / output bandwidth.
[0143] Specifically, the central processor quota can be a CPU occupancy ratio or a computation resource upper limit allocated to the encryption processing thread; and the input / output bandwidth can be a maximum data transmission rate allowed to be used by the socket pair when transmitting the data to be encrypted.
[0144] In one embodiment, based on the manner of determining the preset resource allocation information according to the processing priority, a preset processing priority-resource mapping table can be queried to obtain the preset resource allocation information corresponding to the current processing priority. For example, if the processing priority is high, the corresponding central processor quota is 30%, and the input / output bandwidth is 100 Mbps (megabits per second); if the processing priority is medium, the corresponding central processor quota is 20%, and the input / output bandwidth is 50 Mbps; and if the processing priority is low, the corresponding central processor quota is 10%, and the input / output bandwidth is 20 Mbps.
[0145] S402, creating a socket pair based on the input / output bandwidth and creating an encryption processing thread based on the central processor quota; wherein the socket pair includes a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol.
[0146] In one embodiment, based on the manner of creating the socket pair based on the input / output bandwidth, when creating the socket pair, the system call can be used to set the sending / receiving buffer size, transmission rate upper limit and other parameters of the socket, so that the transmission capacity of the socket pair matches the preset input / output bandwidth standard.
[0147] In one embodiment, based on the manner of creating the encryption processing thread based on the central processor quota, when creating the encryption processing thread, the thread scheduling strategy can be used to allocate the computation resource matching the central processor quota to the encryption processing thread.
[0148] S403, binding the server socket to the encryption processing thread.
[0149] S404, obtaining current resource occupancy information, and in a case where it is identified that the current resource occupancy information cannot meet the preset resource allocation information, determining target resource allocation information corresponding to the encryption request based on the processing priority and the current resource occupancy information.
[0150] The current resource occupancy information can be a real-time system resource usage state of the network-attached storage device when receiving the encryption request.
[0151] In one embodiment, the manner of obtaining the current resource occupancy information can be to call a resource monitoring interface provided by an operating system of the network-attached storage device to obtain the current resource occupancy information.
[0152] The current resource occupation information cannot meet the preset resource allocation information can refer to a case where available resources are insufficient to allocate resources to the encryption request according to the preset resource allocation information, at which time the resource allocation scheme needs to be dynamically adjusted, so the target resource allocation information corresponding to the encryption request is determined based on the processing priority and the current resource occupation information.
[0153] The target resource allocation information can be a resource configuration actually allocable to the encryption request determined according to the processing priority after dynamic adjustment under the current resource occupation state, and can include a target central processing unit quota and a target input / output bandwidth.
[0154] In one embodiment, the manner of determining the target resource allocation information corresponding to the encryption request based on the processing priority and the current resource occupation information can adopt a resource dynamic adjustment algorithm, that is, for the encryption request with a high processing priority, the resource demand is preferentially guaranteed, and the allocated resources of the encryption request with a low processing priority are appropriately reduced to supplement, and for the encryption request with a medium or low processing priority, the currently allocated resources are reduced according to the proportion of available resources to the preset resource allocation information.
[0155] S405, based on the target input / output bandwidth in the target resource allocation information, the client socket is used to transmit the to-be-encrypted data to the server socket, and the encryption processing thread bound to the server socket performs real-time encryption processing on the to-be-encrypted data based on the target central processing unit quota in the target resource allocation information, to obtain an encryption result.
[0156] In one embodiment, based on the target input / output bandwidth in the target resource allocation information, the to-be-encrypted data is transmitted to the server socket through the client socket, which can adopt real-time monitoring of the transmission rate in the data transmission process, and adjusts the data sending frequency, the fragment size and other parameters, so that the actual transmission rate is stabilized in the target input / output bandwidth range.
[0157] In one embodiment, the encryption processing thread bound to the server socket performs real-time encryption processing on the to-be-encrypted data based on the target central processing unit quota in the target resource allocation information to obtain an encryption result, which can adopt dynamic adjustment of the concurrency or time slice proportion of the encryption operation of the encryption processing thread to ensure that the central processing unit usage rate does not exceed the target central processing unit quota.
[0158] The advantage of the scheme is that, by determining the target resource allocation information corresponding to the encryption request based on the processing priority and the current resource occupation information in the case that the current resource occupation information is identified as being unable to meet the preset resource allocation information, dynamic optimization allocation of resources can be realized, resource utilization can be improved, more encryption tasks can be processed in parallel under limited resources, and the overall service efficiency and stability of the network attached storage device are improved.
[0159] Figure 5 is another flow diagram of a real-time encryption method based on a network attached storage device provided by the embodiment of the application. As shown in Figure 5 , the method specifically comprises the following steps:
[0160] S501, in the case that an encryption request sent by a request end is received, a corresponding socket pair and an encryption processing thread are created based on the encryption request; wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol.
[0161] S502, the server socket is bound with the encryption processing thread.
[0162] S503, in the case that encrypted data to be encrypted sent by the request end is received, the encrypted data to be encrypted is transmitted to the server socket through the client socket, and the encrypted data to be encrypted is processed in real time through the encryption processing thread bound with the server socket to obtain an encryption result.
[0163] S504, in the case that a decryption request sent by the request end is received, a corresponding socket pair and a decryption processing thread are created based on the decryption request; wherein the socket pair comprises a server socket and a client socket.
[0164] The decryption request can be an instruction message sent by the request end to the network attached storage device, requiring the encrypted data to be decrypted.
[0165] In an embodiment, the method for receiving the decryption request sent by the request end can be achieved by using a network communication protocol between the request end and the network attached storage device to realize the sending of the decryption request by the request end and the receiving of the decryption request by the main thread.
[0166] Specifically, for the decryption request, the client socket can be a socket in the socket pair that mainly exists in a listening state and is used to receive a data transmission request; and the server socket can be a socket in the socket pair that mainly initiates a connection and is used to send data.
[0167] In one embodiment, based on the manner of creating the corresponding socket pair for the decryption request, the creation can be performed based on the decryption request using a socket programming interface (e.g., a socket() function).
[0168] The decryption processing thread can be a sub-thread specially used for performing a data decryption operation, dynamically created by the main thread according to the decryption request, having an independent execution path, and capable of performing decryption processing on encrypted data corresponding to the decryption request using a preset decryption algorithm without affecting the normal operation of the main thread.
[0169] In one embodiment, based on the manner of creating the corresponding decryption processing thread for the decryption request, the creation can be performed using a multi-thread programming technique (e.g., a pthread_create() function), and the execution environment of the decryption processing thread (including decryption algorithm configuration, decryption key loading, encrypted data address mapping, etc.) is initialized based on the decryption parameters specified in the decryption request. After the creation, the thread state is set to start.
[0170] S505, binding the server socket to the decryption processing thread.
[0171] In one embodiment, the manner of binding the server socket to the decryption processing thread can be to establish a mapping relationship table and store the identification of the server socket and the identification of the decryption processing thread in association.
[0172] S506, receiving, in real time, the decryption processing result of the encrypted data corresponding to the decryption request by the decryption processing thread through the client socket and the server socket, and sending the decryption processing result to the request end in real time.
[0173] The decryption processing result of the encrypted data corresponding to the decryption request can be the original data restored after decryption processing, i.e., the plaintext information consistent with the data to be encrypted before encryption, which can be directly read and used by the request end.
[0174] In one embodiment, the manner of receiving, in real time, the decryption processing result of the encrypted data corresponding to the decryption request by the decryption processing thread through the client socket and the server socket can be that the decryption processing thread sends the data stream of the decryption processing result to the client socket through the server socket in segments, and the client socket receives and splices the segments to form a complete decryption processing result.
[0175] In one embodiment, the manner of sending the decryption processing result to the request end in real time can be to implement real-time sending of the decryption processing result by the main thread and real-time receiving of the decryption processing result by the request end through a network communication protocol between the request end and a network attached storage device.
[0176] Figure 6 is a system architecture diagram of a real-time decryption processing process provided by an embodiment of the present application. As shown in Figure 6 , a decryption processing thread transmits decryption processing results to a client socket in real time through a server socket, so that a main thread receives the decryption processing results in real time and transmits the decryption processing results to a request end in real time.
[0177] Optionally, the method further comprises:
[0178] creating a decryption progress record file to determine a real-time decryption progress position;
[0179] storing the real-time decryption progress position in the decryption progress record file according to a preset period.
[0180] Optionally, after the real-time decryption progress position is stored in the decryption progress record file according to the preset period, the method further comprises:
[0181] determining a decryption interruption position based on the decryption progress record file in the case that a decryption interruption position request sent by the request end is received;
[0182] sending the decryption interruption position to the request end to make the request end resend a decryption request.
[0183] Optionally, after the decryption progress record file is created, the method further comprises:
[0184] generating interruption continuous transmission verification information based on the decryption progress record file and sending the interruption continuous transmission verification information to the request end;
[0185] Correspondingly, the determining of the decryption interruption position based on the decryption progress record file comprises:
[0186] determining the decryption interruption position based on the decryption progress record file in the case that the interruption continuous transmission verification information in the decryption interruption position request sent by the request end is verified to be correct.
[0187] Optionally, the generating of the interruption continuous transmission verification information based on the decryption progress record file comprises:
[0188] generating interruption continuous transmission verification information based on a universal unique identifier of the decryption request and file identification information and generation time information of the decryption progress record file.
[0189] Optionally, before the socket pair and the decryption processing thread are created, the method further comprises:
[0190] determine a processing priority based on the decryption request, and determine preset resource allocation information based on the processing priority; wherein the preset resource allocation information comprises a central processing unit quota and an input / output bandwidth;
[0191] Correspondingly, the creating of the socket pair and the decryption processing thread comprises:
[0192] creating the socket pair based on the input / output bandwidth, and creating the encryption processing thread based on the central processing unit quota;
[0193] Correspondingly, the real-time receiving of the decryption processing result of the encrypted data corresponding to the decryption request by the decryption processing thread through the client socket and the server socket, and the real-time sending of the decryption processing result to the request end comprises:
[0194] obtaining current resource occupation information, and determining target resource allocation information corresponding to the decryption request based on the processing priority and the current resource occupation information in a case where the current resource occupation information is identified as being unable to meet the preset resource allocation information;
[0195] performing real-time decryption processing based on a target central processing unit quota in the target resource allocation information by the decryption processing thread bound to the server socket to obtain a decryption processing result, and transmitting the decryption processing result to the client socket through the server socket based on a target input / output bandwidth in the target resource allocation information.
[0196] The advantage of the scheme is that the corresponding socket pair and decryption processing thread are created based on the decryption request in a case where the decryption request sent by the request end is received, the decryption processing result is received through the socket pair and the decryption processing result is sent to the request end in real time, the decryption process is decoupled from the main thread, the decryption operation does not occupy the main thread resource, the processing efficiency of other requests is not affected, the real-time transmission of the decryption result is ensured by using the local efficient communication characteristics of the socket pair, and the response speed of the request end for obtaining the decryption data is improved.
[0197] Figure 7 is a structural schematic diagram of a real-time encryption device based on a network attached storage device provided by an embodiment of the present application. As shown in Figure 7 the device comprises:
[0198] The creating module 710 is configured to create a corresponding socket pair and encryption processing thread based on the encryption request in a case where the encryption request sent by the request end is received; wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol;
[0199] binding the service end socket with the encryption processing thread;
[0200] encrypting the to-be-encrypted data by the encryption processing thread bound with the service end socket to obtain an encryption result.
[0201] Optionally, the apparatus is further configured to:
[0202] create an encryption progress record file to determine a real-time encryption progress position;
[0203] store the real-time encryption progress position in the encryption progress record file according to a preset period.
[0204] Optionally, the apparatus is further configured to:
[0205] determine an encryption interruption position based on the encryption progress record file upon receiving an encryption interruption position request sent by the request end;
[0206] send the encryption interruption position to the request end to enable the request end to resend an encryption request and resume transmission of the to-be-encrypted data based on the encryption interruption position.
[0207] Optionally, the apparatus is further configured to:
[0208] generate interruption resume transmission verification information based on the encryption progress record file and send the interruption resume transmission verification information to the request end;
[0209] Correspondingly, the determining of the encryption interruption position based on the encryption progress record file comprises:
[0210] determining the encryption interruption position based on the encryption progress record file upon receiving the encryption interruption position request sent by the request end and verifying the interruption resume transmission verification information in the encryption interruption position request.
[0211] Optionally, the apparatus is further configured to:
[0212] generate the interruption resume transmission verification information based on a universally unique identifier of the encryption request and file identification information and generation time information of the encryption progress record file.
[0213] Optionally, the apparatus is further configured to:
[0214] determine a processing priority based on the encryption request, and determine preset resource allocation information based on the processing priority; wherein the preset resource allocation information comprises a central processing unit quota and an input / output bandwidth;
[0215] Correspondingly, the creating module is specifically configured to:
[0216] In a case where the encryption request sent by the request end is received, a socket pair is created based on the input / output bandwidth, and an encryption processing thread is created based on the central processing unit quota; wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol;
[0217] Correspondingly, the encryption module 730 is specifically configured to:
[0218] obtain current resource occupation information, and in a case where it is identified that the current resource occupation information cannot meet the preset resource allocation information, determine target resource allocation information corresponding to the encryption request based on the processing priority and the current resource occupation information;
[0219] based on a target input / output bandwidth in the target resource allocation information, transmit the data to be encrypted to the server socket through the client socket, and perform real-time encryption processing on the data to be encrypted based on a target central processing unit quota in the target resource allocation information through the encryption processing thread bound to the server socket, to obtain an encryption result.
[0220] Optionally, the apparatus is further configured to:
[0221] In a case where the decryption request sent by the request end is received, create a corresponding socket pair and a decryption processing thread based on the decryption request; wherein the socket pair comprises a server socket and a client socket;
[0222] bind the server socket to the decryption processing thread;
[0223] real-time receive a decryption processing result of encrypted data corresponding to the decryption request by the decryption processing thread through the client socket and the server socket, and real-time send the decryption processing result to the request end.
[0224] In the embodiment of the present application, the creating module is configured to create a corresponding socket pair and an encryption processing thread based on the encryption request when receiving the encryption request sent by the request end, wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol; the binding module is configured to bind the server socket and the encryption processing thread; and the encryption module is configured to transmit the to-be-encrypted data to the server socket through the client socket when receiving the to-be-encrypted data sent by the request end, and perform real-time encryption processing on the to-be-encrypted data through the encryption processing thread bound with the server socket to obtain an encryption result. The above real-time encryption device based on the network attached storage device can realize efficient, safe and real-time AES encryption and decryption of the NAS device, and especially for large files or multi-thread access scenarios, the safety, real-time performance and continuity of the encryption and decryption process are improved.
[0225] The real-time encryption device based on the network attached storage device in the embodiment of the present application can be a device, or a component, an integrated circuit or a chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not limited in this regard.
[0226] The real-time encryption device based on the network attached storage device in the embodiment of the present application can be a device with an operating system. The operating system can be an Android operating system, an IOS operating system or other possible operating systems, and the embodiment of the present application is not limited in this regard.
[0227] The real-time encryption device based on the network attached storage device provided in the embodiment of the present application can realize the processes realized by each of the above embodiments, and thus details are not repeated here.
[0228] Figure 8 FIG. 1 is a structural schematic diagram of an electronic device provided in an embodiment of the present application. As shown in FIG. 1, the electronic device comprises a processor 1001, a memory 1002 and a power supply 1003. The processor 1001 is configured to execute a program stored in the memory 1002. The power supply 1003 is configured to supply power to the processor 1001 and the memory 1002. Figure 8As shown, the electronic device 800 includes a processor 801, a memory 802, and a program or instruction stored in the memory 802 and executable on the processor 801. The program or instruction is executed by the processor 801 to implement the processes of the above-mentioned embodiments of the real-time encryption method based on a network-attached storage device, and achieve the same technical effects. To avoid repetition, details are not described herein.
[0229] It should be noted that the electronic device in the embodiments of the present application includes the mobile electronic device and the non-mobile electronic device described above.
[0230] The embodiments of the present application further provide a readable storage medium having a program or instruction stored thereon. The program or instruction is executed by a processor to implement the processes of the above-mentioned embodiments of the real-time encryption method based on a network-attached storage device, and achieve the same technical effects. To avoid repetition, details are not described herein.
[0231] The processor is the processor in the electronic device described in the above-mentioned embodiments. The readable storage medium includes a computer readable storage medium, such as a computer readable memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, etc.
[0232] It should be noted that in this document, the term "comprising" or "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or apparatus including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus including the element. In addition, it should be pointed out that the scope of the methods and apparatus in the embodiments of the present application is not limited to the order of performing the functions as shown or discussed, but can also include performing the functions in a substantially simultaneous manner or in a reverse order, for example, the described method can be performed in an order different from that described, and various steps can be added, omitted or combined. In addition, the features described with reference to certain examples can be combined in other examples.
[0233] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned example method can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a computer software product in essence or in the form of a computer software product that contributes to the prior art. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disc, optical disc), and includes a plurality of instructions for making a terminal (which can be a mobile phone, computer, server, or network device, etc.) execute the method described in each embodiment of the present application.
[0234] The embodiments of the present application are described above in combination with the drawings, but the present application is not limited to the above-mentioned specific embodiments, and the above-mentioned specific embodiments are only illustrative and not restrictive. Those skilled in the art can make many forms under the inspiration of the present application without departing from the scope of the present application and the protection scope of the claims.
[0235] The above are only the preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments described herein, and various obvious changes, readjustments and replacements made by those skilled in the art will not deviate from the scope of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and more other equivalent embodiments can be included without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.
Claims
1. A network attached storage device based real-time encryption method applied to a network attached storage device, characterized in that, The method comprises: In the case of receiving an encryption request sent by a request end, a corresponding socket pair and an encryption processing thread are created based on the encryption request; wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol; The server socket is bound to the encryption processing thread; In the case of receiving unencrypted data sent by the request end, the unencrypted data is transmitted to the server socket through the client socket, and the unencrypted data is processed in real time through the encryption processing thread bound to the server socket to obtain an encryption result; Before the corresponding socket pair and the encryption processing thread are created based on the encryption request, the processing priority is determined based on the encryption request, and the preset resource allocation information is determined based on the processing priority; wherein the preset resource allocation information comprises a central processing unit quota and an input / output bandwidth; The corresponding socket pair is created based on the input / output bandwidth, and the encryption processing thread is created based on the central processing unit quota; The unencrypted data is transmitted to the server socket through the client socket, and the unencrypted data is processed in real time through the encryption processing thread bound to the server socket to obtain an encryption result, which comprises obtaining current resource occupation information, and in the case that the current resource occupation information is identified as unable to meet the preset resource allocation information, the target resource allocation information corresponding to the encryption request is determined based on the processing priority and the current resource occupation information; the unencrypted data is transmitted to the server socket through the client socket based on the target input / output bandwidth in the target resource allocation information, and the unencrypted data is processed in real time through the encryption processing thread bound to the server socket based on the target central processing unit quota in the target resource allocation information to obtain an encryption result.
2. The network attached storage device based real-time encryption method of claim 1, wherein, The method further comprises: Creating an encryption progress record file and determining a real-time encryption progress position; According to a preset period, the real-time encryption progress position is stored in the encryption progress record file.
3. The network attached storage device based real-time encryption method of claim 2, wherein, After the real-time encryption progress position is stored in the encryption progress record file according to the preset period, the method further comprises: In the case of receiving an encryption interruption position request sent by the request end, an encryption interruption position is determined based on the encryption progress record file; The encryption interruption position is sent to the request end, so that the request end re-sends an encryption request and continues to transmit the unencrypted data based on the encryption interruption position.
4. The network attached storage device based real-time encryption method of claim 3, wherein, After the encryption progress record file is created, the method further comprises: Interrupted continuous transmission verification information is generated based on the encryption progress record file, and the interrupted continuous transmission verification information is sent to the request end; Correspondingly, the encryption interruption position is determined based on the encryption progress record file, which comprises: In a case that the encrypted interrupt position request of the request end is received and the interrupt resume verification information in the encrypted interrupt position request is verified, an encrypted interrupt position is determined based on the encrypted progress record file.
5. The network attached storage device based real-time encryption method of claim 4, wherein, The generating interrupt resume verification information based on the encrypted progress record file comprises: The interrupt resume verification information is generated based on the universally unique identification code of the encrypted request and the file identification information and the generation time information of the encrypted progress record file.
6. The network attached storage device based real-time encryption method of claim 1, wherein, After the encrypted result is obtained, the method further comprises: In a case that the decryption request sent by the request end is received, a corresponding socket pair and a decryption processing thread are created based on the decryption request; wherein the socket pair comprises a server socket and a client socket; The server socket is bound to the decryption processing thread; Real-time decryption processing results of the decryption processing thread on encrypted data corresponding to the decryption request are received through the client socket and the server socket, and the decryption processing results are sent to the request end in real time.
7. A network attached storage device based real-time encryption apparatus, characterized by, The device comprises: A creating module is configured to, in a case that an encrypted request sent by a request end is received, create a corresponding socket pair and an encryption processing thread based on the encrypted request; wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol; A binding module is configured to bind the server socket to the encryption processing thread; An encryption module is configured to, in a case that to-be-encrypted data sent by the request end is received, transmit the to-be-encrypted data to the server socket through the client socket, and perform real-time encryption processing on the to-be-encrypted data through the encryption processing thread bound to the server socket, to obtain an encrypted result; The device is further configured to determine a processing priority based on the encrypted request, and determine preset resource allocation information based on the processing priority; wherein the preset resource allocation information comprises a central processing unit quota and an input / output bandwidth; The creating module is specifically configured to, in a case that an encrypted request sent by a request end is received, create a socket pair based on the input / output bandwidth and create an encryption processing thread based on the central processing unit quota; wherein the socket pair comprises a server socket and a client socket, and the server socket and the client socket belong to the same transmission control protocol; The encryption module is specifically configured to: acquire current resource occupation information, and determine target resource allocation information corresponding to the encryption request based on the processing priority and the current resource occupation information in a case where it is identified that the current resource occupation information cannot satisfy the preset resource allocation information; and transmit the data to be encrypted to the service end socket through the client socket based on a target input / output bandwidth in the target resource allocation information, and perform real-time encryption processing on the data to be encrypted based on a target central processing unit quota in the target resource allocation information through the encryption processing thread bound with the service end socket to obtain an encryption result.
8. An electronic device, comprising: A processor, a memory, and a program or instructions stored on the memory and executable on the processor, the program or instructions being executed by the processor to implement the network-attached storage device-based real-time encryption method of any one of claims 1-6.
9. A readable storage medium, characterized by, A program or instructions stored on the readable storage medium, the program or instructions being executed by the processor to implement the network-attached storage device-based real-time encryption method of any one of claims 1-6.
Citation Information
Patent Citations
Communication method, communication device, computer equipment and readable storage medium
CN110768928A
High-efficiency interrupt recoverable image hiding encryption transmission method, device and system
CN111107245A