Key generation method, device, electronic device and storage medium
The key is generated by combining the true random number generator and the line segment folding model with trigonometric function operations, and the problem of easy replication of traditional pseudo-random number keys is solved, and the randomness and security of the key is improved.
Patent Information
- Application Number
- CN202210562145.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-05-23
AI Technical Summary
The keys generated by traditional pseudo-random numbers are easily replicated, have low security, and there is a risk of being listened for copying.
The true random number generator is used to generate the original line segment length value and fold parameters, and the target key is generated by folding arrays and remaining length arrays. Multiple groups of random factors are introduced to superposition, combining the line segment folding model and trigonometric function operation to ensure the randomness and uniqueness of the key.
Improve the security of keys, ensure that the key generation process cannot be simply replicated, and enhance the security and effectiveness of data.
Smart Images

Figure CN114978502B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software security technology, and in particular to a key generation method, a key generation device, an electronic device and a storage medium. Background Art
[0002] In today's digital and networked society, the issue of information digital security has attracted great attention from people, as information digital security is related to people's vital interests in using digital technology.
[0003] Currently, information security is ensured by generating keys based on traditional pseudo-random numbers (e.g., using a deterministic algorithm to calculate a random number sequence uniformly distributed between [0, 1]). Data is then encrypted using the generated key. However, the traditional pseudo-random number generation process is easily replicated, resulting in a high risk of key cracking and a significant possibility of being eavesdropped and copied, resulting in low key security. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention are proposed to provide a key generation method, a key generation device, an electronic device, and a storage medium that overcome the above problems or at least partially solve the above problems.
[0005] In a first aspect of the present invention, an embodiment of the present invention discloses a key generation method, comprising:
[0006] In response to a key generation request, obtaining an original line segment length value and a folding parameter, wherein the original line segment length value and the folding parameter are generated by a random number generator;
[0007] Determine a folding array according to the folding parameters;
[0008] Folding the original line segment corresponding to the original line segment length value using the folding parameter to generate a remaining length array;
[0009] The folded array and the remaining length array are combined to generate a target key.
[0010] Optionally, the method further includes:
[0011] receiving a key update instruction, wherein the key update instruction includes an update period;
[0012] Determining an update time according to the update cycle;
[0013] When the current time matches the update time, the key generation request is generated.
[0014] Optionally, the step of obtaining the original segment length value and the folding parameter in response to the key generation request includes:
[0015] In response to a key generation request, obtaining an original segment length value and a folding number from a random number generator;
[0016] Based on the number of folding times, obtaining, from the random number generator, a number of folding length values equal to the number of folding times;
[0017] The folding times and the folding length are determined as folding parameters.
[0018] Optionally, the step of determining the folding array according to the folding parameters includes:
[0019] Based on the number of folding times, determining a folding order corresponding to the folding length value;
[0020] According to the folding order, the folding length values are arranged to generate a folding array.
[0021] Optionally, the step of folding the original line segments corresponding to the original line segment length values using the folding parameters to generate a remaining length array includes:
[0022] According to the folding order, folding the original line segment corresponding to the original line segment length value by the folding length value to generate a folded line segment;
[0023] Calculating the remaining length corresponding to the folding line segment;
[0024] Arrange the remaining length values according to the folding order to generate a remaining length array.
[0025] Optionally, the step of combining the folded array and the remaining length array to generate a target key includes:
[0026] In the folding array and the remaining length array, determining a target folding length value and a target remaining length value for the same array element position;
[0027] Multiplying the square value of the target remaining length value by the trigonometric function value of the target folded length value to obtain a subkey;
[0028] The subkeys are added together to generate the target key.
[0029] Optionally, the trigonometric function value includes a sine value, a cosine value, and a tangent value; and the step of multiplying the square value of the target remaining length value by the trigonometric function value of the target folded length value to obtain the subkey includes:
[0030] Determine the sine value, cosine value and tangent value as the target trigonometric function values in sequence according to the folding order;
[0031] Converting the target folded length value using the target trigonometric function value to obtain an angle value;
[0032] The square value of the target remaining length value is multiplied by the angle value to obtain a subkey.
[0033] In a second aspect of the present invention, an embodiment of the present invention further discloses a key generation device, comprising:
[0034] a response module, configured to obtain, in response to a key generation request, an original line segment length value and a folding parameter, wherein the original line segment length value and the folding parameter are generated by a random number generator;
[0035] A folding array determination module, configured to determine a folding array according to the folding parameters;
[0036] A folding module, configured to fold the original line segments corresponding to the original line segment length values using the folding parameters to generate a remaining length array;
[0037] A key generation module is used to combine the folded array and the remaining length array to generate a target key.
[0038] In the third aspect of the present invention, an embodiment of the present invention further discloses an electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the key generation method described above when executed by the processor.
[0039] In a fourth aspect of the present invention, an embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the key generation method as described above are implemented.
[0040] The embodiments of the present invention include the following advantages:
[0041] In an embodiment of the present invention, in response to a key generation request, the original segment length value and folding parameters are obtained, where the original segment length value and the folding parameters are generated by a random number generator; a folding array is determined based on the folding parameters; the original segment corresponding to the original segment length value is folded using the folding parameters to generate a remaining length array; and the target key is generated by combining the folding array and the remaining length array. By introducing multiple sets of random factors, the randomness and uniqueness of the key data are guaranteed. Furthermore, a segment folding model is used to ensure that the key generation process cannot be simply replicated, thereby improving data security. The segment folding model can be used for feasibility analysis, increasing the effectiveness of key generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1is a flowchart of a key generation method embodiment of the present invention;
[0043] Figure 2 is a flowchart of another key generation method embodiment of the present invention;
[0044] Figure 3 is a schematic diagram of an example of folding an original line segment of the present invention;
[0045] Figure 4 1 is a flow chart of an example of a key generation method of the present invention;
[0046] Figure 5 It is a structural block diagram of an embodiment of a key generation device of the present invention. DETAILED DESCRIPTION
[0047] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0048] In traditional key generation processes based on pseudorandom numbers, the essence of pseudorandom numbers is the randomness of a mathematical algorithm. The random number output sequence of a mathematical algorithm is completely determined by the initial state and is not unpredictable. Therefore, keys generated using such random numbers still have the potential to be intercepted and replicated. Based on this, the embodiments of this specification propose a key generation scheme.
[0049] Reference Figure 1 , shows a flowchart of a key generation method embodiment of the present invention, which may specifically include the following steps:
[0050] Step 101: In response to a key generation request, obtaining an original segment length value and a folding parameter, wherein the original segment length value and the folding parameter are generated by a random number generator;
[0051] In embodiments of the present invention, a key generator can be used, and a random number generator is external to the key generator to continuously generate random numbers. Random number generation can utilize an image acquisition tool to periodically capture a collection of cloud maps of the target area to generate the final random number. Therefore, the random numbers generated by the random number generator used in embodiments of the present invention are truly random numbers, increasing the randomness and security of the key.
[0052] During information processing, key generation may be required. In this case, the key generator can generate original segment lengths and folding parameters based on a random number generator in response to a key generation request. It should be noted that both the original segment lengths and folding parameters are real numbers. There is no specific requirement for the order in which the original segment lengths and folding parameters are generated. The original segment lengths can be generated first, followed by the folding parameters, or the folding parameters can be generated first, followed by the original segment lengths.
[0053] The scenarios for key generation can be determined based on the actual project processing using the key generator. Key generation scenarios include, but are not limited to, generating keys by encrypting transmitted data in system file transmission scenarios; generating offsets for a single encryption process in multiple encryption processes; generating keys for maintenance projects in projects with periodic key changes (regular updates); generating primary keys for data persistence during database storage operations; and generating serial number splicing in project requests.
[0054] Step 102: Determine a folding array according to the folding parameters.
[0055] After obtaining the folding parameters from the random number generator, the scattered folding parameters can be integrated and summarized as elements in a folding array. The size of the folding array is related to the number of folding parameters generated by the random number generator, and the folding array only includes folding parameters. In addition, it should be noted that the elements in the folding array are different from each other, that is, the same numerical value does not exist in a folding array. For example, when the folding array is a one-dimensional array, the folding array A = [1, 2, 3, 4, 5, 6]; the same numerical value will not appear repeatedly in the folding array, further enhancing the randomness and security of the key. The type of the folding array is not limited in the embodiment of the present invention.
[0056] In a preferred example of the invention, the line segment corresponding to the original line segment length value is a one-dimensional straight line, and the folded array is a one-dimensional array.
[0057] Step 103: fold the original line segments corresponding to the original line segment length values using the folding parameters to generate a remaining length array.
[0058] In practical applications, after obtaining the original segment length, the original segment corresponding to the original segment length value can be determined in the simulation space. The original segment can be a one-dimensional original segment. To reduce the amount of data to be processed, the start and end points of the one-dimensional original segment can be omitted from the calculation, and only the length of the one-dimensional original segment can be considered for subsequent processing. The unit of the original segment length is also not limited; it can be meters, decimeters, centimeters, or even millimeters. However, the original segment length must be consistent with the length-related parameters in the folding parameters. For example, if the unit of the original segment length is centimeters, the unit of the corresponding length-related parameters in the folding parameters is also centimeters.
[0059] Based on the original segment, the original segment is folded several times using the folding parameters. The remaining length of the original segment after each fold is recorded and the remaining length values are used as elements of the remaining length array to generate a remaining length array. Therefore, the number of elements in the remaining length array is the same as the number of elements in the folding array. For example, if the original segment length is 10 and the folding array A = [2, 3], the remaining length B after folding the original segment corresponding to the original segment length value using the folding array is [8, 5].
[0060] Step 104: Combine the folded array and the remaining length array to generate a target key.
[0061] After obtaining the folded data and the remaining length array, a mathematical model can be constructed based on the folded array and the remaining length array, and arithmetic operations can be performed on the elements in the folded array and the remaining length array to generate a specific operation result. The operation result can be directly used as the target key and the target key can be used.
[0062] In an embodiment of the present invention, in response to a key generation request, the original segment length value and folding parameters are obtained, where the original segment length value and the folding parameters are generated by a random number generator; a folding array is determined based on the folding parameters; the original segment corresponding to the original segment length value is folded using the folding parameters to generate a remaining length array; and the target key is generated by combining the folding array and the remaining length array. By introducing multiple sets of random factors, the randomness and uniqueness of the key data are guaranteed. Furthermore, a segment folding model is used to ensure that the key generation process cannot be simply replicated, thereby improving data security. The segment folding model can be used for feasibility analysis, increasing the effectiveness of key generation.
[0063] Reference Figure 2 , shows a flowchart of another key generation method embodiment of the present invention, which may specifically include the following steps:
[0064] Step 201: Receive a key update instruction, where the key update instruction includes an update period.
[0065] In an embodiment of the present invention, it can be applied to a key generator, which is an internal service in a running program. The user can generate a key update instruction through user operation according to the need to generate a key. The key update instruction is used to guide the time for key update; the key update instruction carries an update cycle. Among them, the update cycle can be a specific time point, such as 3:00 a.m. on Monday, or it can be the frequency of update, once a week. The size of the update cycle can be set according to needs, such as updating at 3:00 a.m. every Monday, Wednesday, Friday, and Saturday; updating at 3:00 a.m. every Tuesday, Thursday, and Saturday; updating every 8 hours; updating when the system iterates the update function and restarts. The key generator receives the key update instruction; the embodiment of the present invention does not specifically limit it.
[0066] Step 202: Determine the update time according to the update cycle.
[0067] After determining the update cycle, add the update cycle to the last update time to determine the next update time. For example, if the update cycle is every 8 hours and the last update time was 06:00 on 2022 / 5 / 11, 8 hours are added to 06:00 on 2022 / 5 / 11 to determine the update time of 14:00 on 2022 / 5 / 11. It should be noted that when the system is undergoing its first update, the update time can be set to the current time.
[0068] Step 203: When the current time matches the update time, a key generation request is generated.
[0069] Continuously obtain the current time of the running program and compare it with the update time. When the obtained current time matches the update time, it can be determined that the current time matches the update time, and a key generation request is generated. For example, if the update time is 2022 / 5 / 11, 14:00, and the current time is obtained as 2022 / 5 / 11, 13:59, it does not match the update time 2022 / 5 / 11, 14:00. The current time is obtained again as 2022 / 5 / 11, 14:00, which matches the update time 2022 / 5 / 11, 14:00, and a key generation request is generated. In addition, to reduce data processing accuracy, the matching range can be determined within a certain threshold range of the update time. The threshold range can be configured as needed, such as one minute before or after, three minutes before or after, etc.
[0070] Step 204 : In response to the key generation request, obtain the original line segment length value and the folding parameter, wherein the original line segment length value and the folding parameter are generated by a random number generator.
[0071] In an embodiment of the present invention, the random number generator is an external service in the running program. The random number generator collects a target area of the image based on the image in the resource pool, and determines a true random number through the atlas of the target area cloud map.
[0072] After the key generation request is generated, the key generator may respond to the key generation request and obtain the random number generated by the random number generator as the original line segment length value and the folding parameter.
[0073] Specifically, the step of obtaining the original line segment length value and the folding parameter in response to the key generation request may include:
[0074] Sub-step S2041 , in response to a key generation request, obtaining an original line segment length value and a folding count from a random number generator;
[0075] In practical applications, the key generator, in response to a key generation request, obtains an original segment length value and a folding count from a random number generator. If the folding count is not a positive integer, it must be corrected to a positive integer. Rounding methods include, but are not limited to, rounding up and rounding down. The original segment length value must be a positive number, and there are no specific restrictions on numerical precision.
[0076] Sub-step S2042: Based on the folding times, obtaining the same number of folding length values as the folding times from the random number generator.
[0077] Based on the number of folds, the number of random numbers to be obtained from the random number generator again is determined; and the same number of fold length values as the number of folds are obtained from the random number generator. A single fold length value must be less than the remaining length of the line segment, and the values obtained from a single fold length value are not repeated. If the random number generator generates two repeated values, the subsequent repeated value is discarded, and another random number is regenerated as the fold length value. Specifically, after the random number generator generates a random number, the random number can be judged. If the same random number exists, the random number is discarded; if the same random number does not exist, the random number is used as the fold length value. For example, the random number generator needs to generate 5 random numbers as fold length values, and generates 1, 2, 3, 4, and 4 in sequence. Since 4 appears repeatedly, the subsequent "4" is discarded, and the random number 5 is re-obtained from the random number generator. The fold length values are then determined to be 1, 2, 3, 4, and 5.
[0078] Sub-step S2042: determining the folding times and the folding length value as folding parameters.
[0079] After obtaining the folding times and folding length values, the folding times and the multiple folding length values are determined as folding parameters.
[0080] Step 205: Determine a folding array according to the folding parameters.
[0081] In practical applications, the values in the folding parameters are stored in a one-dimensional array to generate a folding array.
[0082] Specifically, the step of determining the folding array according to the folding parameters may include:
[0083] Sub-step S2051: determining a folding order corresponding to the folding length value based on the folding number.
[0084] Based on the number of folding times, for the folding length value of each folding, the folding order corresponding to all the folding length values is determined from the first folding to the last folding.
[0085] Sub-step S2052: Arrange the folding length values according to the folding order to generate a folding array.
[0086] According to the folding order, the folding length values are stored in the folding array in turn. After all the folding lengths are arranged, the folding array is generated.
[0087] If the number of folding times is 3, the folding length value obtained from the random number generator is 1 for the first folding, 2 for the second folding, and 3 for the third folding, and the folding array C = [1, 2, 3] is generated according to the folding order.
[0088] Step 206: fold the original line segments corresponding to the original line segment length values using the folding parameters to generate a remaining length array.
[0089] In practical applications, the original line segment corresponding to the original line segment length value is used as the physical model, and the folding length value in the folding parameter is used to fold the physical model in sequence. The remaining length of the physical model after each folding is recorded to generate a remaining length array.
[0090] Specifically, the step of folding the original line segments corresponding to the original line segment length values by using the folding parameters to generate a remaining length array may include:
[0091] Sub-step S2061, folding the original line segment corresponding to the original line segment length value by the folding length value according to the folding order to generate a folded line segment;
[0092] In practical applications, the folding length value required for this folding can be determined according to the folding sequence. For the original line segment corresponding to the original line segment length value, the corresponding length value is folded from one side to generate a folded line segment. When folding again, it is necessary to fold from the same side.
[0093] Sub-step S2062, calculating the remaining length corresponding to the folding line segment;
[0094] The length of the folded segment after folding is used as the remaining length. Specifically, during the first folding, the remaining length can be obtained by subtracting the folded length from the original segment length. During the second or subsequent folding, the remaining length of the previous folding can be used as the original length, and the new remaining length can be obtained by subtracting the folded length from the original length.
[0095] Sub-step S2063: Arrange the remaining length values according to the folding order to generate a remaining length array.
[0096] After repeating sub-steps S2061 to S2062, multiple remaining length values are obtained, and the remaining length values are stored in an array according to the folding order to generate a remaining length array.
[0097] You can refer to Figure 3 , which shows a schematic diagram of an example of folding an original line segment according to the present invention, Figure 3 The process of four foldings is shown in the figure. In the first folding, the folding length value is Z1. After folding the original line segment, the remaining length value is L1; in the second folding, the folding length value is Z2. The first folded line segment is folded as the original line segment, and the remaining length value is L2; in the third folding, the folding length value is Z3. The second folded line segment is folded as the original line segment, and the remaining length value is L3; in the fourth folding, the folding length value is Z4. The third folded line segment is folded as the original line segment, and the remaining length value is L4; the remaining length values are arranged in the folding order to generate a remaining length array L = [L1, L2, L3, L4].
[0098] Step 207: Combine the folded array and the remaining length array to generate a target key.
[0099] The folding array and the remaining length array are combined according to a preset mathematical model, and the result of the operation is used as the target key.
[0100] Specifically, the step of generating a target key by combining the folded array and the remaining length array may include:
[0101] Sub-step S2071, determining the target folding length value and the target remaining length value of the same array element position in the folding array and the remaining length array.
[0102] During the calculation, first determine the folding length value and the remaining length value of the same folding from the folding array and the remaining length array, that is, determine the folding length value and the remaining length value of the same array element as the target folding length value and the target remaining length value.
[0103] Sub-step S2072: multiply the square value of the target remaining length value by the trigonometric function value of the target folded length value to obtain a sub-key.
[0104] Then, for the target remaining length value, calculate the square value corresponding to the target remaining length value; for the target folded length value, calculate the trigonometric function value corresponding to the target folded length value, multiply the square value corresponding to the target remaining length value by the trigonometric function value corresponding to the target folded length value to obtain an intermediate calculation result, and use the intermediate budget result as the subkey.
[0105] In a preferred embodiment of the present invention, the trigonometric function values include sine, cosine, and tangent values; and the step of multiplying the square of the target remaining length value by the trigonometric function value of the target folded length value to obtain the subkey may specifically include:
[0106] Sub-step S20721, determining the sine value, cosine value, and tangent value in sequence as target trigonometric function values according to the folding order;
[0107] In the embodiment of the present invention, the trigonometric function values can be sine, cosine, and tangent. Furthermore, the three trigonometric functions can be used cyclically, i.e., sine, cosine, and tangent are used in sequence according to the folding order. For example, if the folding is performed five times, the trigonometric function values used in sequence are: sine, cosine, tangent, sine, and cosine.
[0108] When calculating the subkey, the sine value, cosine value and tangent value can be used cyclically in sequence according to the folding order as the target trigonometric function value for this subkey calculation.
[0109] Sub-step S20722, converting the target folded length value using the target trigonometric function value to obtain an angle value;
[0110] After determining the target trigonometric function value, the target folded length value is converted using the corresponding trigonometric function to generate an angle value, wherein the angle value can be in radians or degrees.
[0111] Sub-step S20723: multiply the square of the target remaining length value by the angle value to obtain a sub-key.
[0112] Finally, the square of the target remaining length is multiplied by the angle value, and the result is the subkey.
[0113] Sub-step S2073, adding the sub-keys to generate a target key.
[0114] The subkeys obtained at the target remaining length value and the target folded length value of each fold are added to obtain a final operation result, which is the target key.
[0115] That is, the calculation result of the key can be expressed as follows:
[0116] R=L1 2 *SIN(Z1)+L2 2 *COS(Z2)+L3 2 *TAN(Z3)+...+SIN(Zn-2)+COS(Zn-1)+TAN(Zn);
[0117] Wherein, Ln is the remaining length value, Zn is the folded length value, R is the target key; and N is a positive integer.
[0118] In this embodiment of the present invention, by introducing a physical model of line segment folding and folding based on the folded length value to form a corresponding array of remaining length values, the key generation process is guaranteed to be unreplicable, thereby improving data security. Combined with trigonometric functions, the key generation pattern is more random, significantly increasing data security. Converting numerical values into angles for calculation increases the computational complexity of key generation and makes it less susceptible to cracking. Furthermore, periodic key updates can avoid the risk of human leakage and fixed key leaks, thereby improving key security.
[0119] In order to enable those skilled in the art to better understand the embodiments of the present invention, the embodiments of the present invention are described below using an example:
[0120] Reference Figure 4 , which shows a flow chart of an example of a key generation method of the present invention.
[0121] In response to a key generation request, on one hand, an original segment length value is obtained from a random number generator, and an original segment of corresponding length in space is determined. On the other hand, the number of folds X and the position of each fold (fold length value) are obtained from the random number generator, and the fold positions are organized into an array Z.
[0122] Then, the original line segment is folded based on the folding position, and the remaining length after each folding is recorded, which is the array L;
[0123] Then the arrays Z and L are calculated based on the following formulas:
[0124] R=L1 2 *SIN(Z1)+L2 2 *COS(Z2)+L32 *TAN(Z3)+...+SIN(Zn-2)+COS(Zn-1)+TAN(Zn);
[0125] The result of the operation is the target key R;
[0126] Finally, the target key R is persisted and used in the project.
[0127] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0128] Reference Figure 5 , shows a structural block diagram of an embodiment of a key generation device of the present invention, which may specifically include the following modules:
[0129] A response module 501 is configured to obtain an original segment length value and a folding parameter in response to a key generation request, where the original segment length value and the folding parameter are generated by a random number generator;
[0130] A folding array determining module 502 is configured to determine a folding array based on the folding parameters;
[0131] A folding module 503 is configured to fold the original line segment corresponding to the original line segment length value using the folding parameter to generate a remaining length array;
[0132] The key generation module 504 is configured to combine the folded array and the remaining length array to generate a target key.
[0133] In a preferred embodiment of the present invention, the device further comprises:
[0134] A receiving module, configured to receive a key update instruction, wherein the key update instruction includes an update period;
[0135] An update time determination module, configured to determine an update time according to the update cycle;
[0136] The request generation module is used to generate the key generation request when the current time matches the update time.
[0137] In a preferred embodiment of the present invention, the response module 501 includes:
[0138] A response submodule, configured to obtain an original line segment length value and a folding number from a random number generator in response to a key generation request;
[0139] A random generation submodule, configured to obtain, based on the number of folding times, from the random number generator a number of folding length values that is equal to the number of folding times;
[0140] The folding parameter determination submodule is used to determine the folding times and the folding length value as folding parameters.
[0141] In a preferred embodiment of the present invention, the folding array determination module 502 includes:
[0142] A folding sequence determination submodule, configured to determine a folding sequence corresponding to the folding length value based on the number of folding times;
[0143] The first arrangement submodule is used to arrange the folding length values according to the folding order to generate a folding array.
[0144] In a preferred embodiment of the present invention, the folding module 503 includes:
[0145] A first folding submodule is configured to fold the original line segment corresponding to the original line segment length value by the folding length value according to the folding order to generate a folded line segment;
[0146] A remaining length calculation submodule, used to calculate the remaining length corresponding to the folding line segment;
[0147] The second arrangement submodule is used to arrange the remaining length values according to the folding order to generate a remaining length array.
[0148] In a preferred embodiment of the present invention, the key generation module 504 includes:
[0149] a target determination submodule, configured to determine a target folded length value and a target remaining length value of the same array element position in the folded array and the remaining length array;
[0150] a subkey calculation module, configured to obtain a subkey by multiplying the square of the target remaining length value by a trigonometric function value of the target folded length value;
[0151] The key generation submodule is used to add the subkeys to generate a target key.
[0152] In a preferred embodiment of the present invention, the trigonometric function values include sine, cosine, and tangent values; and the subkey calculation module includes:
[0153] A target trigonometric function determining unit, configured to determine, in sequence according to the folding order, a sine value, a cosine value, and a tangent value as target trigonometric function values;
[0154] a trigonometric function value calculation module, configured to convert the target folded length value using the target trigonometric function value to obtain an angle value;
[0155] The subkey calculation unit is configured to multiply the square of the target remaining length value by the angle value to obtain a subkey.
[0156] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0157] An embodiment of the present invention further provides an electronic device, including:
[0158] A processor and a storage medium storing a computer program executable by the processor. When the electronic device is running, the processor executes the computer program to perform the method as described in any of the embodiments of the present invention. The specific implementation methods and technical effects are similar to those in the method embodiments and are not further described here.
[0159] The present invention also provides a computer-readable storage medium having a computer program stored thereon. The computer program, when executed by a processor, executes the method according to any one of the embodiments of the present invention. The specific implementation and technical effects are similar to those of the method embodiments and will not be further described here.
[0160] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0161] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0162] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0163] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0164] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0165] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0166] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0167] The key generation method, device, electronic device and storage medium provided by the present invention are introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A key generation method, characterized in that: include: In response to a key generation request, obtaining an original line segment length value and a folding parameter, wherein the original line segment length value and the folding parameter are generated by a random number generator; Determine a folding array according to the folding parameters; The folding array is obtained by summarizing scattered folding parameters as elements; Folding the original line segment corresponding to the original line segment length value using the folding parameter to generate a remaining length array; the remaining length array is obtained by summing the remaining length of the original line segment after each folding as an element; The folded array and the remaining length array are combined to generate a target key.
2. The method according to claim 1, characterized in that The method further comprises: receiving a key update instruction, wherein the key update instruction includes an update period; Determining an update time according to the update cycle; When the current time matches the update time, the key generation request is generated.
3. The method according to any one of claims 1 to 2, characterized in that The step of obtaining the original line segment length value and the folding parameter in response to the key generation request includes: In response to a key generation request, obtaining an original segment length value and a folding number from a random number generator; Based on the number of folding times, obtaining, from the random number generator, a number of folding length values equal to the number of folding times; The folding times and the folding length are determined as folding parameters.
4. The method according to claim 3, characterized in that The step of determining the folding array according to the folding parameters includes: Based on the number of folding times, determining a folding order corresponding to the folding length value; According to the folding order, the folding length values are arranged to generate a folding array.
5. The method according to claim 4, characterized in that The step of folding the original line segments corresponding to the original line segment length values by using the folding parameters to generate a remaining length array comprises: According to the folding order, folding the original line segment corresponding to the original line segment length value by the folding length value to generate a folded line segment; Calculating the remaining length corresponding to the folding line segment; Arrange the remaining length values according to the folding order to generate a remaining length array.
6. The method according to claim 5, characterized in that The step of generating a target key by combining the folded array and the remaining length array comprises: In the folding array and the remaining length array, determining a target folding length value and a target remaining length value for the same array element position; Multiplying the square value of the target remaining length value by the trigonometric function value of the target folded length value to obtain a subkey; The subkeys are added together to generate the target key.
7. The method according to claim 6, characterized in that The trigonometric function values include sine, cosine, and tangent values; and the step of multiplying the square of the target remaining length value by the trigonometric function value of the target folded length value to obtain the subkey includes: Determine the sine value, cosine value and tangent value as the target trigonometric function values in sequence according to the folding order; Converting the target folded length value using the target trigonometric function value to obtain an angle value; The square value of the target remaining length value is multiplied by the angle value to obtain a subkey.
8. A key generation device, characterized in that: include: a response module, configured to obtain, in response to a key generation request, an original line segment length value and a folding parameter, wherein the original line segment length value and the folding parameter are generated by a random number generator; A folding array determination module, configured to determine a folding array according to the folding parameters; The folding array is obtained by summarizing scattered folding parameters as elements; a folding module, configured to fold the original line segments corresponding to the original line segment length values using the folding parameters to generate a residual length array; the residual length array is obtained by summarizing the residual lengths of the original line segments after each folding as elements; A key generation module is used to combine the folded array and the remaining length array to generate a target key.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the key generation method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the key generation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Three-dimensional mapping fast image encryption method
CN108629723A
Ciphering method and device therefor
JP2003195756A