Disclosure of Invention
The application aims to provide an OFD document encryption method. The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview and is intended to neither identify key/critical elements nor delineate the scope of such embodiments. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
According to an aspect of an embodiment of the present application, there is provided an OFD document encryption method, including:
and 5 processes are adopted, 1 process is selected from the 5 processes to be used as a main process to execute encryption operation, and the other 4 processes are standby.
Further, the selecting 1 process from the 5 processes as a master process to perform an encryption operation includes:
the 5 processes are encrypted simultaneously; the 5 processes comprise a first process, a second process, a third process, a fourth process and a fifth process;
if the first process finishes encryption firstly, respectively sending a notification of selecting a main process to the other 4 processes, and after receiving the notification of the first process, pausing encryption speed measurement and sending a confirmation signal to the first process by the second process, the third process, the fourth process and the fifth process;
collecting the confirmation signals of the second process, the third process, the fourth process and the fifth process by the first process, and accumulating the number of the confirmation signals, and recording the number as N;
the first process sends N to a second process, a third process, a fourth process and a fifth process respectively, and after the second process receives N, if N is 3, the node candidate is confirmed to be successful, and the second process enters a standby state; after the third process receives the N, if the N is greater than 3, the first process candidate is confirmed to be successful, and a standby state is entered; after receiving the N, if N ≧ 3, the fourth process determines that the first process candidate is successful, and enters a standby state; after the fifth process receives the N, if the N is greater than 3, the first process candidate is confirmed to be successful, and a standby state is entered;
until the first process is successfully selected, the process starts to execute the encryption task; the first process sends a state identifier of 'working' to the other 4 processes respectively at regular time while executing the encryption task, and the 4 processes determine that the first process is in an 'active' state after receiving the state identifier and still keep a standby state.
Further, the method further comprises:
if the candidate process enters a 'false death' state in the running process, namely the candidate process becomes a 'zombie' process, the encryption work can not be executed any more, at the moment, the rest 4 processes can not receive the state identification of 'working' of the first process any more, then 4 processes start the process encryption speed measurement, and a main process is reselected.
Further, said reselecting a host process comprises:
and if the third process completes encryption firstly, the third process sends a notice of selecting the main process to the second process, the fourth process and the fifth process respectively, and after receiving the notice, the second process, the fourth process and the fifth process suspend encryption speed measurement and send a confirmation signal to the third process.
After receiving the confirmation signals of all the other processes, the third process accumulates the number of the confirmation signals and respectively sends the number to all the other processes, after receiving the number, the other processes respectively judge whether the number is more than 2, if the number is more than 2, the third process is confirmed to be successful in candidate, the third process starts to execute the encryption task, the other processes enter a standby state, similarly, the third process respectively sends a state identifier of 'working' to 3 other processes at regular time while executing the encryption task, and after receiving the state identifier, the 3 processes determine that the third process is in an 'active' state and still keep the standby state.
Further, the method further comprises:
if the second process and the fourth process complete the encryption speed measurement first, the second process and the fourth process are not allowed to send a notification of selecting the main process mutually;
and the second process sends a notice of selecting the main process to the first process, the third process and the fifth process, the first process, the third process and the fifth process send confirmation signals to the second process after receiving the notice, and the second process accumulates the number of the confirmation signals after receiving the confirmation signals.
And the fourth process sends a main process notification to the first process, the third process and the fifth process, the first process, the third process and the fifth process send confirmation signals to the fourth process after receiving the notification, and the fourth process accumulates the number of the confirmation signals after receiving the confirmation signals.
Further, the method further comprises: if only 4 processes are used for selecting the main process and more than 2 processes simultaneously complete the encryption speed measurement, the election cannot be successful, the encryption speed measurement needs to be restarted, and a new round of main process selection is started.
Further, the new round of selection main process comprises: recording the 4 processes as a first process, a second process, a third process and a fourth process respectively;
if the first process and the second process finish encryption speed measurement first, because the first process and the second process are candidates, the first process and the second process are not allowed to send a notification of selecting a main process to each other;
the first process sends a notice of selecting the main process to the third process and the fourth process, the third process and the fourth process send confirmation signals to the first process after receiving the notice, the first process accumulates the quantity of the confirmation signals, the total quantity is 2 after receiving the confirmation signals, the quantity of the confirmation signals is respectively sent to the other 2 processes, and after the third process and the fourth process receive the quantity of the confirmation signals, the third process and the fourth process find that the quantity of the confirmation signals does not exceed half of the total quantity of the processes, and then the first process candidate is unsuccessful.
Likewise, the second process candidate is also unsuccessful.
And (4) as the first process and the second process are not successfully selected, all the processes restart encryption speed measurement and start a new round of main selection process.
According to another aspect of the embodiments of the present application, there is provided an electronic apparatus including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor executing the program to implement the above-described encryption method for an OFD document.
According to another aspect of embodiments of the present application, there is provided a computer-readable storage medium having stored thereon a computer program, which is executed by a processor, to implement the above-described encryption method of an OFD document.
The technical scheme provided by one aspect of the embodiment of the application can have the following beneficial effects:
the encryption method for the OFD document, provided by the embodiment of the application, adopts a multi-process encryption mode, improves the encryption fault tolerance rate, avoids the problem of a single-process mode, and can ensure uninterrupted encryption service.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the embodiments of the application, or may be learned by the practice of the embodiments. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It will be understood by those within the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
As shown in fig. 1, an embodiment of the present application provides an encryption method for an OFD document, including:
and 5 processes are adopted, 1 process is selected from the 5 processes to be used as a main process to execute encryption operation, and the other 4 processes are standby.
In order to avoid the problem of 'false death' possibly brought by a single process, the OFD document is encrypted by adopting 5 processes, 1 process is selected as a main process to execute encryption work in a consensus mode, and the other 4 processes are in standby.
For better description, 5 processes are respectively denoted as process 1, process 2, process 3, process 4, and process 5. The following describes how a process is selected to perform encryption on a set of data, see fig. 2 and 3:
1) starting 5 processes in the background, encrypting the data by the 5 processes simultaneously, wherein the encryption algorithm adopts symmetric encryption, the algorithm generally adopts AES, SM4 and other algorithms, and the 5 processes are not malicious processes and are completely trusted.
2) If the process 1 finishes encryption first, a notification of selecting a main process is sent to the other 4 processes (shown in fig. 2), and after the processes 2, 3, 4 and 5 receive the notification of the process 1, encryption speed measurement is suspended, and a confirmation signal is sent to the process 1;
3) the process 1 collects the confirmation signals of the process 2, the process 3, the process 4 and the process 5, and accumulates the number of the confirmation signals, and records the number as N;
4) the process 1 sends N to the process 2, the process 3, the process 4 and the process 5, respectively, and after the process 2 receives N, if N ≧ 3, the node candidate is confirmed to be successful, and the node candidate enters a standby state; after receiving N, if N > ═ 3, process 3 determines that process 1 candidate is successful and enters a standby state, after receiving N, process 4 determines that process 1 candidate is successful and enters a standby state if N > ═ 3, and after receiving N, process 5 determines that process 1 candidate is successful and enters a standby state if N > ═ 3;
5) by this point, process 1 candidate is successful and the process starts to perform the encryption task. As shown in fig. 3, while the process 1 executes the encryption task, it sends a "working" status identifier to the remaining 4 processes at regular time, and after receiving the status identifiers, the 4 processes recognize that the process 1 is in an "active" status, and still maintain a standby status.
In the above description, in the normal operation process, if the candidate process enters a "dead" state during the operation, that is, the candidate process becomes a "zombie" process, the encryption operation cannot be executed any more, and at this time, the remaining 4 processes cannot receive the state identifier of "working" in the process 1 any more, then 4 processes start the process encryption speed measurement, and a main process is reselected, and the steps are as follows:
1) if the process 3 completes encryption firstly, the process 3 sends a notification of selecting a main process to the process 2, the process 4 and the process 5 respectively, and after receiving the notification, the process 2, the process 4 and the process 5 suspend encryption speed measurement and send a confirmation signal to the process 3.
2) After receiving the confirmation signals of all the other processes, the process 3 accumulates the number of the confirmation signals, and respectively sends the number to all the other processes, after receiving the number, the other processes respectively judge whether the number is larger than 2, if the number is larger than 2, the process 3 is confirmed to be successful in candidate, the process 3 starts to execute the encryption task, the other processes enter a standby state, similarly, the process 3 respectively sends a state identifier of 'working' to the other 3 processes at regular time while executing the encryption task, and after receiving the state identifier, the 3 processes determine that the process 3 is in an 'active' state and still maintain the standby state.
In addition, after the process 1 in the "false death" state is restarted, the process directly enters the standby state to wait for the next round of candidates.
If more than 2 processes in the 5 processes complete the encryption speed measurement, the main process election specifically comprises the following processes:
1) if the process 2 and the process 4 firstly complete encryption speed measurement, as the process 2 and the process 4 are both candidates, the process 2 and the process 4 are not allowed to mutually send a notification of selecting a main process;
2) the process 2 sends a notice of selecting the main process to the process 1, the process 3 and the process 5, the process 1, the process 3 and the process 5 send confirmation signals to the process 2 after receiving the notice, and the process 2 accumulates the quantity of the confirmation signals after receiving the confirmation signals.
3) Meanwhile, the process 4 sends a main process notification to the processes 1, 3 and 5, the processes 1, 3 and 5 send acknowledgement signals to the process 4 after receiving the notification, and the process 4 accumulates the number of the acknowledgement signals after receiving the acknowledgement signals.
4) And if the process 2 and the process 4 are equal in ticket number and cannot be successfully selected, the encryption speed measurement needs to be restarted and a new process of selecting the main process is started.
If only 4 processes are selected and more than 2 processes simultaneously complete the encryption speed measurement, the race selection cannot be successful, the encryption speed measurement needs to be restarted, and a new process of selecting the main process is started. The 4 processes are respectively marked as process 1, process 2, process 3 and process 4, and the specific processes are described as follows:
1) if the process 1 and the process 2 finish encryption speed measurement first, as the process 1 and the process 2 are candidates, the process 1 and the process 2 are not allowed to send a notification of selecting a main process;
2) the process 1 sends a notification of selecting a main process to the process 3 and the process 4, the process 3 and the process 4 send confirmation signals to the process 1 after receiving the notification, the process 1 accumulates the number of the confirmation signals, the total number is 2, the number of the confirmation signals is respectively sent to the other 2 processes, and after the process 3 and the process 4 receive the number of the confirmation signals, the process 1 candidate is not successful if the number of the confirmation signals is found to be less than half of the total number of the processes (the value is 4).
3) Likewise, the process 2 candidate is also unsuccessful.
4) And (4) as the process 1 and the process 2 are not successfully selected, all the processes restart encryption speed measurement and start a new process of selecting the main process.
In conclusion, the consensus algorithm for selecting one process to execute the encryption task is adopted, so that the method has the main advantages of improving the fault tolerance rate of encryption, avoiding the problems of a single-process mode and ensuring uninterrupted encryption service.
The embodiment of the application adopts a multi-process encryption mode, the main process of the encryption process is selected by using the consensus algorithm, and after the main process is in a 'false death' state, the main process is reselected from other standby processes by using the consensus algorithm, so that the phenomenon of encryption task failure caused by the 'false death' of one process is avoided, the fault tolerance rate of encryption service is improved, the encryption service is stably and uninterruptedly provided for a user, the user experience is improved, and the operation and maintenance cost is saved because manual restart is not needed.
It should be noted that:
the term "module" is not intended to be limited to a particular physical form. Depending on the particular application, a module may be implemented as hardware, firmware, software, and/or combinations thereof. Furthermore, different modules may share common components or even be implemented by the same component. There may or may not be clear boundaries between the various modules.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. In addition, this application is not directed to any particular programming language. It will be appreciated that a variety of programming languages may be used to implement the teachings of the present application as described herein, and any descriptions of specific languages are provided above to disclose the best modes of the present application.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the application, various features of the application are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: this application is intended to cover such departures from the present disclosure as come within known or customary practice in the art to which this invention pertains. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this application.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The above-mentioned embodiments only express the embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.