Data encryption methods, devices, electronic equipment and storage media
By using the bit count of the random number and the value parameters processed by the pi circle in the data encryption process, and encrypting it in combination with the timestamp, the problem of insufficient encryption due to the correlation of random number generation is solved, and the security of data encryption is improved.
Patent Information
- Application Number
- CN202210899408.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-28
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2042-07-28
AI Technical Summary
During the data encryption process, the generation of random numbers has inherent correlations with the recursive function, resulting in low discreteness of random sequence values, which in turn makes the data encryption insufficient and cannot guarantee the security of the data.
By responsive to the data encryption instruction, user data and encryption parameters, including the number of bits of a random number and the value parameters for pi-slicing circle processing. Then, the pi is cut in circle according to these parameters, and the result value of the cut in circle is obtained, and the random number is calculated in combination with the timestamp, which is used to encrypt the user data.
By adjusting the number of bits of random numbers, the encryption degree is improved, and the random number is generated by combining the timestamp and the result value of the cut circle is generated, which improves the discreteness of the random numbers, thereby enhancing the security of data encryption.
Smart Images

Figure CN115333737B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data encryption, and in particular to a data encryption method, a data encryption device, an electronic device and a computer-readable storage medium. Background Art
[0002] With the development of computer networks, the recording and transmission of information has become more and more convenient, and the value of information has become higher and higher. However, protecting the transmission of private information and ensuring that important information is not stolen has become a major problem. Among them, data security is the foundation for the sustainable development of enterprises and the key to ensuring the privacy of personal users. Under normal circumstances, for private data, private data can be encrypted by corresponding key encryption to ensure the security of private data. In the process of encrypting data, the generation of random numbers is often involved. The security of data encryption is improved by using random numbers as a variable in the encryption process. In this process, there is an inherent correlation in the recursive function for the generation of random numbers, which makes the discrete degree of the random sequence values generated by it low, resulting in insufficient data encryption, and thus the security of the data cannot be guaranteed. Summary of the invention
[0003] The embodiments of the present invention provide a data encryption method, device, electronic device and computer-readable storage medium to solve or partially solve the problem in the related art that the data encryption degree is insufficient during the data encryption process, resulting in low data encryption security.
[0004] The embodiment of the present invention discloses a data encryption method, comprising:
[0005] In response to a data encryption instruction, obtaining user data corresponding to the data encryption instruction and encryption parameters for the user data, the encryption parameters at least including the number of bits of a random number and a value parameter for performing a circumcision process on pi;
[0006] Performing a circle division process on the pi according to the number of bits and the value parameter to obtain a circle division result value corresponding to the encryption parameter;
[0007] Obtaining a timestamp corresponding to the data encryption instruction, and calculating a random number for the user data according to the timestamp and the circle cutting result value;
[0008] The user data is encrypted using the random number to generate corresponding encrypted user data.
[0009] Optionally, the performing a circumscribing process on the pi according to the number of digits and the value parameter to obtain a circumscribing result value corresponding to the encryption parameter includes:
[0010] Using the digits and the value parameter to perform a circle-slicing process on the pi to obtain a first approximate value corresponding to the pi;
[0011] The first approximate value is converted into a second approximate value in binary, and the second approximate value is left-shifted according to the number of bits to obtain a circle-cutting result value corresponding to the encryption parameter.
[0012] Optionally, the performing left shift processing on the second approximate value according to the number of bits to obtain a circle-cutting result value corresponding to the encryption parameter includes:
[0013] Randomly select a first random value from zero to the number of bits;
[0014] The number of bits corresponding to the first random value is shifted left in the second approximate value to obtain a third approximate value, and the third approximate value is converted into a decimal system to obtain a rounding result value corresponding to the encryption parameter.
[0015] Optionally, before converting the third approximate value into a decimal system to obtain the circle-cutting result value corresponding to the encryption parameter, left-shifting the second approximate value according to the number of bits to obtain the circle-cutting result value corresponding to the encryption parameter further includes:
[0016] If the third approximate value is a negative number, returning to the step of randomly selecting a first random value from zero to the number of digits to obtain a second random value;
[0017] The second approximate value is left-shifted according to the second random value until a third approximate value of a positive number is obtained after the left-shift is completed.
[0018] Optionally, the timestamp is a millisecond timestamp, and the calculating of a random number for the user data according to the timestamp and the circle cutting result value includes:
[0019] Calculate the common divisor between the millisecond timestamp and the circle cutting result value;
[0020] When the length of the common divisor is the same as the value of the number of bits, the calculation of the common divisor is stopped, and the obtained common divisor is used as a random number for the user data.
[0021] Optionally, the value parameter is generated in the following manner:
[0022] Obtaining a coefficient for the number of bits;
[0023] Calculate a first initial value using the coefficient and the number of bits;
[0024] Taking the square root of the difference between the first preset value and the square of the first initial value as the second initial value;
[0025] The square root of the second preset value and the second initial value is used as the value parameter.
[0026] The embodiment of the present invention also discloses a data encryption device, including:
[0027] A data acquisition module, configured to respond to a data encryption instruction and acquire user data corresponding to the data encryption instruction and encryption parameters for the user data, wherein the encryption parameters at least include the number of bits of a random number and a value parameter for performing a circle division process on pi;
[0028] A circle-cutting processing module, used for performing circle-cutting processing on the pi according to the number of digits and the value parameter to obtain a circle-cutting result value corresponding to the encryption parameter;
[0029] A random number generation module, used to obtain a timestamp corresponding to the data encryption instruction, and calculate a random number for the user data according to the timestamp and the circle cutting result value;
[0030] The data encryption module is used to encrypt the user data using the random number to generate corresponding encrypted user data.
[0031] Optionally, the circle cutting processing module is specifically used for:
[0032] Using the digits and the value parameter to perform a circle-slicing process on the pi to obtain a first approximate value corresponding to the pi;
[0033] The first approximate value is converted into a second approximate value in binary, and the second approximate value is left-shifted according to the number of bits to obtain a circle-cutting result value corresponding to the encryption parameter.
[0034] Optionally, the circle cutting processing module is specifically used for:
[0035] Randomly select a first random value from zero to the number of bits;
[0036] The number of bits corresponding to the first random value is shifted left in the second approximate value to obtain a third approximate value, and the third approximate value is converted into a decimal system to obtain a rounding result value corresponding to the encryption parameter.
[0037] Optionally, the circle cutting processing module is further used for:
[0038] If the third approximate value is a negative number, returning to the step of randomly selecting a first random value from zero to the number of digits to obtain a second random value;
[0039] The second approximate value is left-shifted according to the second random value until a third approximate value of a positive number is obtained after the left-shift is completed.
[0040] Optionally, the timestamp is a millisecond timestamp, and the random number generation module is specifically used for:
[0041] Calculate the common divisor between the millisecond timestamp and the circle cutting result value;
[0042] When the length of the common divisor is the same as the value of the number of bits, the calculation of the common divisor is stopped, and the obtained common divisor is used as a random number for the user data.
[0043] Optionally, the value parameter is generated by the following module:
[0044] A coefficient acquisition module, used for acquiring coefficients for the number of bits;
[0045] A first calculation module, used to calculate a first initial value using the coefficient and the number of bits;
[0046] A second calculation module, configured to take a square root corresponding to a difference between a first preset value and a square of the first initial value as a second initial value;
[0047] A third calculation module is used to take the square root of the second preset value and the second initial value as the value parameter.
[0048] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0049] The memory is used to store computer programs;
[0050] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0051] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0052] The embodiments of the present invention include the following advantages:
[0053] In an embodiment of the present invention, when data needs to be encrypted, user data corresponding to the data encryption instruction and encryption parameters for the user data can be obtained in response to the data encryption instruction, the encryption parameters at least including the number of bits of the random number and the value parameters for circumscribing pi, then circumscribing pi according to the number of bits and the value parameters to obtain the circumscribing result values corresponding to the encryption parameters, and obtaining the timestamp corresponding to the data encryption instruction, then calculating the random number for the user data according to the timestamp and the circumscribing result value, and then encrypting the user data with the random number to generate the corresponding encrypted user data, so that when encrypting the data, on the one hand, the encryption degree can be set by adjusting the number of bits of the random number, thereby improving the flexibility of data encryption, and on the other hand, the random number for encrypting the data is generated based on the number of bits of the random number, the value parameters and the timestamp during the encryption process, thereby improving the discreteness of the random number and thus improving the security of the user data encryption. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 is a flowchart of a method for encrypting data provided in an embodiment of the present invention;
[0055] Figure 2 is a schematic diagram of a data encryption process provided in an embodiment of the present invention;
[0056] Figure 3 is a structural block diagram of a data encryption device provided in an embodiment of the present invention;
[0057] Figure 4 It is a block diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0058] 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.
[0059] As an example, data security is the foundation for the sustainable development of an enterprise and the key to ensuring the privacy of individual users. Under normal circumstances, private data can be encrypted through corresponding key encryption to ensure the security of private data. In the process of encrypting data, the generation of random numbers is often involved. The security of data encryption is improved by using random numbers as a variable in the encryption process. However, in this process, there is an inherent correlation in the recursive function for the generation of random numbers, which makes the generated random sequence values not discrete enough, resulting in insufficient data encryption, and thus the security of the data cannot be guaranteed.
[0060] In this regard, one of the core inventions of the present invention is to optimize the random number generation process based on the pi-circle-cutting method and the Euclidean algorithm, improve the discreteness of the random number, and then encrypt the data based on the random number to improve the security of data encryption. Specifically, when the data needs to be encrypted, the user data corresponding to the data encryption instruction and the encryption parameters for the user data can be obtained by responding to the data encryption instruction, and the encryption parameters at least include the number of bits of the random number and the value parameters for circumscribing the pi, and then the pi can be circumscribing according to the number of bits and the value parameters to obtain the circumscribing result value corresponding to the encryption parameter, and obtain the timestamp corresponding to the data encryption instruction, and then the random number for the user data is calculated according to the timestamp and the circumscribing result value, and then the random number is used to encrypt the user data to generate the corresponding encrypted user data, so that when the data is encrypted, on the one hand, the encryption degree can be set by adjusting the number of bits of the random number, thereby improving the flexibility of data encryption, and on the other hand, the random number for encrypting the data is generated based on the number of bits of the random number, the value parameters and the timestamp in the encryption process, thereby improving the discreteness of the random number, and thus improving the security of user data encryption.
[0061] Reference Figure 1 , shows a flowchart of a method for encrypting data provided in an embodiment of the present invention, which may specifically include the following steps:
[0062] Step 101, in response to a data encryption instruction, obtaining user data corresponding to the data encryption instruction and encryption parameters for the user data, wherein the encryption parameters at least include the number of bits of a random number and a value parameter for performing a circumcision process on pi;
[0063] In an embodiment of the present invention, data encryption instructions may include data transmission instructions and data storage instructions, etc., then the terminal (device that performs encryption processing on data) can respond to the data transmission instruction to obtain user data corresponding to the data transmission instruction, or respond to the data storage instruction to obtain user data corresponding to the data storage instruction. While obtaining the user data, encryption parameters for the user data can be obtained so as to generate corresponding random numbers through the encryption parameters, and then the user data is encrypted through the random numbers to ensure the security of the user data.
[0064] The encryption parameters may include the number of digits of the subsequently generated random number and the value parameters for dividing pi. For example, assuming that the subsequent random number is 10 digits, the number of digits may be 10.
[0065] Optionally, for the value parameter, it can be a value calculated according to the number of bits of the set random number. Specifically, the coefficient for the number of bits can be obtained, and the coefficient and the number of bits can be used to calculate the first initial value, and then the square root corresponding to the difference between the first preset value and the square of the first initial value is used as the second initial value, and then the square root between the second preset value and the second initial value is used as the value parameter. Among them, the coefficient can be a fixed value, and the value between the first preset value and the second preset value can be a fixed value, which can be set according to actual needs, and the present invention is not limited to this.
[0066] In an example, assuming that the value parameter is y and the number of bits of the random number is n, the coefficient can be set to 1, the first preset value can be set to 4, and the second preset value can be set to 2. Then, the first initial value y1 can be n*1, y2 can be the square root of (4-(y1*y1)), and then y can be calculated, which can be 2-y2. The value parameter is calculated by the set number of bits of the random number, which improves the randomness of data encryption, and then improves the discreteness of the subsequently generated random numbers to ensure the security of data encryption.
[0067] Step 102, performing a circle division process on the pi according to the number of digits and the value parameter to obtain a circle division result value corresponding to the encryption parameter;
[0068] In the embodiment of the present invention, by setting the number of digits of the random number and the value parameter obtained according to the number of digits, the pi can be processed by cutting the circle to obtain the corresponding result value of cutting the circle. Among them, the processing of cutting the circle of pi can be carried out by the corresponding method of cutting the circle. Specifically, the formula corresponding to the method of cutting the circle can be: π≈3*2^n*y_n, wherein n is the number of times the circle is cut, that is, the number of digits of the random number, and y_n represents the length of each side of the regular 6*n-gon embedded in the circle (such as when n is 1, it corresponds to a regular hexagon; when n is 2, it corresponds to a regular dodecagon, etc.), so that the processing of cutting the circle of pi can be realized by the method of cutting the circle to obtain the corresponding result value of cutting the circle.
[0069] In a specific implementation, the number of digits and the value parameter can be used to perform a circumcision process on pi to obtain a first approximate value corresponding to pi, and then the first approximate value is converted into a second approximate value in binary, and the second approximate value is left-shifted according to the number of digits to obtain a circumcision result value corresponding to the encryption parameter. For the left-shift process of the second approximate value, a first random value can be randomly selected from zero to the number of digits, and then the number of digits corresponding to the first random value is left-shifted in the second approximate value to obtain a third approximate value, and the third approximate value is converted into a decimal system to obtain a circumcision result value corresponding to the encryption parameter. At the same time, if the third approximate value is a negative number, the step of randomly selecting a first random value between zero and the number of bits can be returned to obtain a new second random value, and then the second approximate value is left-shifted according to the new second random value until a third approximate value of a positive number is obtained after the left shift is completed, so as to further perform a decimal conversion on the third approximate value to obtain a circumcision result value corresponding to the encryption parameter, thereby performing a circumcision process on pi through the set number of bits of the random number and the value parameter generated according to the number of bits, thereby improving the randomness of the encryption during the encryption process, so as to improve the discreteness of the random numbers generated subsequently.
[0070] In one example, by substituting the value parameter y and the number of digits n of the random number into the circle-cutting formula, the corresponding first approximation K can be obtained. At this time, the first approximation K is a decimal, and the first approximation K can be converted into a binary system to obtain a second approximation E1, and then the random value can be determined based on the number of digits n. Assuming n is 10, a random value can be taken from 0-10. When the random value is 5, the second approximation E1 can be shifted left by 5 bits (assuming the second approximation E is 10001111, a 5-bit left shift can obtain 11100000), and then the corresponding third approximation E2 can be obtained after the left shift, and the third approximation E2 can be converted into a decimal system to obtain the corresponding circle-cutting result value G. Before performing the decimal conversion, it can be determined whether the third approximation E2 is a positive number. If it is not a positive number, it can return to the step of randomly taking a value from 0-10, and re-take a value, such as re-taking a value of 6, and then the aforementioned left shift process can be repeated to ensure that the circle-cutting result value G is not a negative number.
[0071] Step 103, obtaining a timestamp corresponding to the data encryption instruction, and calculating a random number for the user data according to the timestamp and the circle cutting result value;
[0072] After obtaining the corresponding circle cutting result value through the circle cutting method, in order to further improve the discreteness of the random number, the timestamp corresponding to the data encryption instruction can be obtained, and then the calculation can be performed based on the timestamp and the circle cutting result value to finally obtain the random number for the user data. Therefore, when encrypting the data, on the one hand, the encryption degree can be set by adjusting the number of bits of the random number, which improves the flexibility of data encryption. On the other hand, the random number used to encrypt the data is generated based on the number of bits of the random number, the value parameters and the timestamp during the encryption process, which improves the discreteness of the random number and thus improves the security of user data encryption.
[0073] Among them, for the timestamp, it can be a millisecond timestamp, that is, it can be a thirteen-digit timestamp, and the common divisor between the millisecond timestamp and the circle cutting result value can be calculated by the Euclidean algorithm. When the length of the common divisor is the same as the value of the number of digits, the calculation of the common divisor is stopped, and the obtained common divisor is used as a random number for the user data.
[0074] In one example, assuming that the number of bits of the random number is 10, when the common divisor between the millisecond timestamp and the result value of the circle division is calculated by Euclid, if the length of the common divisor is 13, the second calculation of the common divisor is performed. If the length of the common divisor calculated for the second time is 10, the calculation of the common divisor can be stopped, and the 10-digit common divisor can be directly used as the random number for the user data. After the corresponding result value of the circle division is obtained by dividing the pi by the circle division method, the random number is generated in combination with the timestamp corresponding to the data encryption instruction. On the one hand, the encryption degree can be set by adjusting the number of bits of the random number, thereby improving the flexibility of data encryption. On the other hand, since the timestamp is unique, the randomness of the data encryption is improved. At the same time, the random number used to encrypt the data is generated based on the number of bits of the random number, the value parameters and the timestamp, which effectively improves the discreteness of the random number, thereby improving the security of user data encryption.
[0075] Step 104: encrypt the user data using the random number to generate corresponding encrypted user data.
[0076] After obtaining the corresponding random number through the above process, the user data can be encrypted based on the random number combined with the corresponding encryption algorithm to generate the corresponding encrypted user data, and then the encrypted user data can be transmitted or stored to ensure the security of the user data.
[0077] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It is understandable that those skilled in the art can also make settings according to actual needs under the guidance of the ideas of the embodiments of the present invention, and the present invention is not limited to this.
[0078] In an embodiment of the present invention, when data needs to be encrypted, user data corresponding to the data encryption instruction and encryption parameters for the user data can be obtained in response to the data encryption instruction, the encryption parameters at least including the number of bits of the random number and the value parameters for circumscribing pi, then circumscribing pi according to the number of bits and the value parameters to obtain the circumscribing result values corresponding to the encryption parameters, and obtaining the timestamp corresponding to the data encryption instruction, then calculating the random number for the user data according to the timestamp and the circumscribing result value, and then encrypting the user data with the random number to generate the corresponding encrypted user data, so that when encrypting the data, on the one hand, the encryption degree can be set by adjusting the number of bits of the random number, thereby improving the flexibility of data encryption, and on the other hand, the random number for encrypting the data is generated based on the number of bits of the random number, the value parameters and the timestamp during the encryption process, thereby improving the discreteness of the random number and thus improving the security of the user data encryption.
[0079] In order to enable those skilled in the art to better understand the technical solution of the embodiment of the present invention, an example is given below for illustrative explanation:
[0080] Reference Figure 2 , which shows a schematic diagram of a data encryption process provided in an embodiment of the present invention,
[0081] 1. When data encryption is required, the user can enter the number of circle cuts (the number of digits of the random number subsequently generated) n;
[0082] 2. For y in the circle cutting formula, you can use n*1.0 as the initial value y1, the square root of 4-(y1*y1) as y2, and the square root of 2-y2 as y;
[0083] 3. Substitute y and n into the circle-cutting formula π≈3*2^n*y_n to obtain the first approximation K;
[0084] 4. Since K is a decimal, K can be converted into binary to obtain the second approximate value E1;
[0085] 5. Randomly select a value from 0-n to obtain a random value, and shift E1 left by the number of bits corresponding to the random value to obtain the third approximate value E2. Then it can be determined whether E2 is a negative number. If not, perform a decimal conversion to obtain the corresponding circle cutting result value G; if it is a negative number, re-select the value;
[0086] 6. Get the millisecond timestamp T corresponding to the encrypted instruction;
[0087] 7. Obtain the common divisor through the Euclidean algorithm gcd(T,G). When the length of the common divisor is consistent with n, output the random number G;
[0088] 8. Encrypt the data using the random number G to obtain the corresponding encrypted data.
[0089] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but 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 the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0090] Reference Figure 3 , shows a structural block diagram of a data encryption device provided in an embodiment of the present invention, which may specifically include the following modules:
[0091] The data acquisition module 301 is used to respond to the data encryption instruction and acquire the user data corresponding to the data encryption instruction and the encryption parameters for the user data, wherein the encryption parameters at least include the number of bits of the random number and the value parameters for performing the circumcision process on pi;
[0092] A circle-cutting processing module 302 is used to perform circle-cutting processing on the pi according to the number of digits and the value parameter to obtain a circle-cutting result value corresponding to the encryption parameter;
[0093] A random number generation module 303 is used to obtain a timestamp corresponding to the data encryption instruction, and calculate a random number for the user data according to the timestamp and the circle cutting result value;
[0094] The data encryption module 304 is used to encrypt the user data using the random number to generate corresponding encrypted user data.
[0095] In an optional embodiment, the circle cutting processing module 302 is specifically used for:
[0096] Using the digits and the value parameter to perform a circle-slicing process on the pi to obtain a first approximate value corresponding to the pi;
[0097] The first approximate value is converted into a second approximate value in binary, and the second approximate value is left-shifted according to the number of bits to obtain a circle-cutting result value corresponding to the encryption parameter.
[0098] In an optional embodiment, the circle cutting processing module 302 is specifically used for:
[0099] Randomly select a first random value from zero to the number of bits;
[0100] The number of bits corresponding to the first random value is shifted left in the second approximate value to obtain a third approximate value, and the third approximate value is converted into a decimal system to obtain a rounding result value corresponding to the encryption parameter.
[0101] In an optional embodiment, the circle cutting processing module 302 is further configured to:
[0102] If the third approximate value is a negative number, returning to the step of randomly selecting a first random value from zero to the number of digits to obtain a second random value;
[0103] The second approximate value is left-shifted according to the second random value until a third approximate value of a positive number is obtained after the left-shift is completed.
[0104] In an optional embodiment, the timestamp is a millisecond timestamp, and the random number generation module 303 is specifically used to:
[0105] Calculate the common divisor between the millisecond timestamp and the circle cutting result value;
[0106] When the length of the common divisor is the same as the value of the number of bits, the calculation of the common divisor is stopped, and the obtained common divisor is used as a random number for the user data.
[0107] In an optional embodiment, the value parameter is generated by the following module:
[0108] A coefficient acquisition module, used for acquiring coefficients for the number of bits;
[0109] A first calculation module, used to calculate a first initial value using the coefficient and the number of bits;
[0110] A second calculation module, configured to take a square root corresponding to a difference between a first preset value and a square of the first initial value as a second initial value;
[0111] A third calculation module is used to take the square root of the second preset value and the second initial value as the value parameter.
[0112] 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.
[0113] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned data encryption method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0114] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned data encryption method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0115] Figure 4 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0116] The electronic device 400 includes but is not limited to: a radio frequency unit 401, a network module 402, an audio output unit 403, an input unit 404, a sensor 405, a display unit 406, a user input unit 407, an interface unit 408, a memory 409, a processor 410, and a power supply 411. Those skilled in the art will appreciate that the electronic device structure involved in the embodiments of the present invention does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0117] It should be understood that in the embodiment of the present invention, the radio frequency unit 401 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 410 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 401 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 401 can also communicate with the network and other devices through a wireless communication system.
[0118] The electronic device provides users with wireless broadband Internet access through the network module 402, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0119] The audio output unit 403 can convert the audio data received by the RF unit 401 or the network module 402 or stored in the memory 409 into an audio signal and output it as sound. Moreover, the audio output unit 403 can also provide audio output related to a specific function performed by the electronic device 400 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 403 includes a speaker, a buzzer, a receiver, etc.
[0120] The input unit 404 is used to receive audio or video signals. The input unit 404 may include a graphics processor (GPU) 4041 and a microphone 4042, and the graphics processor 4041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 406. The image frame processed by the graphics processor 4041 can be stored in the memory 409 (or other storage medium) or sent via the radio frequency unit 401 or the network module 402. The microphone 4042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 401 in the case of a telephone call mode.
[0121] The electronic device 400 also includes at least one sensor 405, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 4061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 4061 and / or the backlight when the electronic device 400 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 405 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0122] The display unit 406 is used to display information input by the user or information provided to the user. The display unit 406 may include a display panel 4061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0123] The user input unit 407 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 407 includes a touch panel 4071 and other input devices 4072. The touch panel 4071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 4071 or near the touch panel 4071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 4071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 410, receives the command sent by the processor 410 and executes it. In addition, the touch panel 4071 can be implemented using various types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 4071, the user input unit 407 may also include other input devices 4072. Specifically, other input devices 4072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail here.
[0124] Further, the touch panel 4071 may be covered on the display panel 4061. When the touch panel 4071 detects a touch operation on or near it, it is transmitted to the processor 410 to determine the type of the touch event, and then the processor 410 provides a corresponding visual output on the display panel 4061 according to the type of the touch event. It can be understood that in one embodiment, the touch panel 4071 and the display panel 4061 are used as two independent components to implement the input and output functions of the electronic device, but in some embodiments, the touch panel 4071 and the display panel 4061 can be integrated to implement the input and output functions of the electronic device, which is not limited here.
[0125] The interface unit 408 is an interface for connecting an external device to the electronic device 400. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 408 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 400 or may be used to transmit data between the electronic device 400 and an external device.
[0126] The memory 409 can be used to store software programs and various data. The memory 409 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 409 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0127] The processor 410 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 409, and calling data stored in the memory 409, so as to monitor the electronic device as a whole. The processor 410 may include one or more processing units; preferably, the processor 410 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 410.
[0128] The electronic device 400 may also include a power supply 411 (such as a battery) for supplying power to each component. Preferably, the power supply 411 may be logically connected to the processor 410 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0129] In addition, the electronic device 400 includes some functional modules not shown, which will not be described in detail here.
[0130] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0131] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0132] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0133] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0134] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0135] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0136] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0137] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0138] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0139] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A data encryption method, characterized in that: include: In response to a data encryption instruction, obtaining user data corresponding to the data encryption instruction and encryption parameters for the user data, the encryption parameters at least including the number of bits of a random number and a value parameter for performing a circumcision process on pi; Performing a circle division process on the pi according to the number of bits and the value parameter to obtain a circle division result value corresponding to the encryption parameter; Obtaining a timestamp corresponding to the data encryption instruction, and calculating a random number for the user data according to the timestamp and the circle cutting result value; The user data is encrypted using the random number to generate corresponding encrypted user data.
2. The method according to claim 1, characterized in that The performing a circumscribing process on the pi according to the number of bits and the value parameter to obtain a circumscribing result value corresponding to the encryption parameter includes: Using the digits and the value parameter to perform a circle-slicing process on the pi to obtain a first approximate value corresponding to the pi; The first approximate value is converted into a second approximate value in binary, and the second approximate value is left-shifted according to the number of bits to obtain a circle-cutting result value corresponding to the encryption parameter.
3. The method according to claim 2, characterized in that The step of left-shifting the second approximate value according to the number of bits to obtain a circle-cutting result value corresponding to the encryption parameter includes: Randomly select a first random value from zero to the number of bits; The number of bits corresponding to the first random value is shifted left in the second approximate value to obtain a third approximate value, and the third approximate value is converted into a decimal system to obtain a rounding result value corresponding to the encryption parameter.
4. The method according to claim 3, characterized in that Before converting the third approximate value into a decimal system to obtain the rounding result value corresponding to the encryption parameter, the second approximate value is left-shifted according to the number of bits to obtain the rounding result value corresponding to the encryption parameter, and further includes: If the third approximate value is a negative number, returning to the step of randomly selecting a first random value from zero to the number of digits to obtain a second random value; The second approximate value is left-shifted according to the second random value until a third approximate value of a positive number is obtained after the left-shift is completed.
5. The method according to claim 1, characterized in that The timestamp is a millisecond-level timestamp, and the calculating of a random number for the user data according to the timestamp and the circle-cutting result value includes: Calculate the common divisor between the millisecond timestamp and the circle cutting result value; When the length of the common divisor is the same as the value of the number of bits, the calculation of the common divisor is stopped, and the obtained common divisor is used as a random number for the user data.
6. The method according to claim 1, characterized in that The value parameters are generated in the following way: Obtaining a coefficient for the number of bits; Calculate a first initial value using the coefficient and the number of bits; Taking the square root of the difference between the first preset value and the square of the first initial value as the second initial value; The square root of the second preset value and the second initial value is used as the value parameter.
7. A data encryption device, characterized in that: include: A data acquisition module, configured to respond to a data encryption instruction and acquire user data corresponding to the data encryption instruction and encryption parameters for the user data, wherein the encryption parameters at least include the number of bits of a random number and a value parameter for performing a circle division process on pi; A circle-cutting processing module, used for performing circle-cutting processing on the pi according to the number of digits and the value parameter to obtain a circle-cutting result value corresponding to the encryption parameter; A random number generation module, used to obtain a timestamp corresponding to the data encryption instruction, and calculate a random number for the user data according to the timestamp and the circle cutting result value; The data encryption module is used to encrypt the user data using the random number to generate corresponding encrypted user data.
8. The device according to claim 7, characterized in that The circle cutting processing module is specifically used for: Using the digits and the value parameter to perform a circle-slicing process on the pi to obtain a first approximate value corresponding to the pi; The first approximate value is converted into a second approximate value in binary, and the second approximate value is left-shifted according to the number of bits to obtain a circle-cutting result value corresponding to the encryption parameter.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 6 when executing the program stored in the memory.
10. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for establishing random number table of digits behind pi decimal point
CN108776583A
Chinese data compression and synchronous encryption method and system based on circumference ratio PI
CN112507665A