An irrational number encryption method
The use of irrational numbers in a function matrix to generate random numbers addresses periodicity and size constraints, providing flexible and uniform data encryption suitable for diverse encryption applications.
Patent Information
- Application Number
- CN202110461552.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-27
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-04-27
AI Technical Summary
In the prior art, random number generation algorithms have periodic limits and size limits, which are difficult to meet the needs of high-security data encryption.
The irrational number generation method is used to generate random numbers without periods and size limits through function matrix or construction method, and perform division conversion to meet different needs, and file encryption is used to use the characteristics of irrational numbers.
The generated random numbers have no cycle limits and no size limits, and are highly flexible. They can achieve complete encryption of computer files and improve the security of data transmission and transactions.
Smart Images

Figure CN113111366B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data encryption and random number generation, and particularly to an irrational number encryption method. Background Art
[0002] With the development of society, technology is constantly innovating. Especially in the aspect of computer networks, with the development of artificial intelligence, global informatization has become a major trend in global development. However, due to the increasingly rampant behaviors of hackers, virus invasions, and information leaks, the network information security problems seriously hinder the development of the network economy and social progress. Therefore, in order to ensure data transmission security and transaction security and create a safe technological environment, a series of security technologies must be adopted, such as the most common encryption technology, face recognition, digital signature, identity authentication, etc.
[0003] An irrational number is an infinite non-repeating decimal. For example, the constant π = 3.1415926…… We can use the characteristics of irrational numbers to generate a series of digital sequences. Since the generated digital sequences are non-periodic and the intercepted sequences are also non-periodic, if irrational numbers are applied to specific computer files for encryption operations, it will be beneficial to improve the security of data encryption. Summary of the Invention
[0004] The purpose of the present invention is to provide a random number generation method without periodic limitations, without size limitations, and with high flexibility, and apply it to the irrational number encryption method.
[0005] To achieve the above purpose, the technical solution provided by the present invention is as follows:
[0006] An irrational number encryption method, comprising the following steps:
[0007] S1. Generate an irrational number after removing the decimal point;
[0008] S2. According to different random number requirements, perform a radix conversion on the irrational number generated in step S1 after removing the decimal point to obtain a random number within a range;
[0009] Since in programming, files need to be read byte by byte, and the data content of one byte is between 0 and 255. If the encrypted digital string S always takes decimal numbers, that is, numbers between 0 and 9, then it will lead to incomplete encryption. If the original decimal encrypted digital string S is converted to a 256 - radix, then at this time, each digit in S on each radix is also between 0 and 255, so that the complete encryption of computer files byte by byte can be achieved. Therefore, the radix conversion of irrational numbers is particularly important.
[0010] S3. Extract a part from the irrational number as the encrypted digital string S;
[0011] S4, processing the target file into blocks;
[0012] S5. Use the numbers in the digital string S to encrypt each block of file data to obtain ciphertext.
[0013] Furthermore, the step S1 generates irrational numbers using a function matrix or a construction method.
[0014] Furthermore, the function matrix is composed of a plurality of functional formulas, and the irrational number is formed by connecting the calculation results of the plurality of functional formulas.
[0015] Furthermore, when designing a function matrix, it is necessary to estimate the generation result of the function matrix; and in order to enhance randomness, several additional functions are added on the basis of each function.
[0016] Furthermore, the generating of irrational numbers by the construction method includes connecting prime numbers within a specified range to form irrational numbers.
[0017] Furthermore, in step S2, when a random integer between 0 and n needs to be generated and n is a positive integer, assuming that the irrational number n=d0+10×d1+10 2 ×d2+……, it needs to be converted into a p-base number, that is, n=c0+p×c1+p 2 ×c2+……, the conversion is performed according to the first base. The specific process of the first base conversion is as follows:
[0018] (1) Determine the relationship between the current integer n and p. If n <p,则转换结束;
[0019] (2) If n≥p, find the remainder c0, c0=n%p;
[0020] (3) Perform the operation n′=(n-c0) / p, then we get n′=c1+p×c2+p 2 ×c3+......, to find c1, we need to find the remainder with respect to n′, that is, c1=n′%p;
[0021] (4) By analogy, repeat the above method to obtain the remaining digits in turn and finally realize the base conversion.
[0022] Further, in step S2, when it is necessary to generate a random integer between [-m, -n], [-n, m], [-m, n] or [n, m] and n and m are positive integers, and m>n, a binary conversion is performed, specifically: by adding or subtracting the upper and lower limits, the lower limit becomes 0, that is, converting to the first base conversion for processing; after the first base conversion is completed, the number previously added or subtracted from the upper and lower limits is supplemented, and the result falls back to the original required range;
[0023] When it is necessary to generate a random number between a and b, where a and b are positive decimals, a ternary conversion is performed. Specifically: First, check which decimal place the random number is required to be accurate to. If the random number is accurate to 1 decimal place after the decimal point, multiply the upper and lower limits by 10. If the random number is accurate to 2 decimal places after the decimal point, multiply the upper and lower limits by 10 2 , and so on; then perform the conversion according to the binary conversion; after generating a random integer, divide it by the number multiplied before to obtain the random number required originally.
[0024] Compared with the prior art, the principle and advantages of this solution are as follows:
[0025] 1. Compared with the pseudo-random numbers relied on by traditional algorithms that have certain periodic limitations, the pseudo-random numbers generated by this solution using irrational numbers have no periodic limitations and can be approximated infinitely as long as there are sufficient resources.
[0026] 2. Compared with the pseudo-random numbers generated by traditional algorithms that have size limitations, the pseudo-random numbers generated by this solution using irrational numbers have no size limitations and can generate extremely large numbers with an approximately infinite length.
[0027] 3. In this solution, the function matrix for generating irrational numbers is composed of multiple functional expressions, using multivariate origin functions or multiple different origin functions. When the variables or functions change, the generated random number results will also be different, with high flexibility.
[0028] 4. With the support of computing power, the function matrix in this solution can theoretically calculate infinitely, and as the number of generated random numbers increases, the occurrence times will be more uniform.
[0029] 5. The random numbers generated by this solution are calculated in real time and can be reproduced, without the need to calculate in advance and occupy additional storage space.
[0030] 6. The principle of this solution is relatively simple and intuitive, and it is not difficult to implement, without a very high technical threshold, and it is a civilianized random number generation method.
[0031] 7. The random number generation method involved in this solution solves the problem of the source of random numbers required in many industrial and scientific research scenarios, especially various encryption algorithms. Because encryption algorithms require a certain degree of irregularity so that it is not easy for crackers to master the rules. Therefore, this solution can be combined with other encryption algorithms to form a new algorithm. Description of the Drawings
[0032] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the services required for the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0033] Figure 1 It is a principle flowchart of an irrational number encryption method of the present invention;
[0034] Figure 2 It is a schematic diagram of the function matrix in the embodiment;
[0035] Figure 3 It is a statistical result graph of the occurrence times of each digit (i.e., 0 to 9) in an irrational number digital sequence containing a large number of digits;
[0036] Figure 4 It is a schematic diagram of probability uniformity;
[0037] Figure 5 It is a statistical result graph of random numbers generated in the range of [0, 20];
[0038] Figure 6 It is a computer experiment graph of generating ultra-large random numbers. Specific embodiments
[0039] The present invention will be further described below in conjunction with specific embodiments:
[0040] Such as Figure 1 shown, an irrational number encryption method described in an embodiment of the present invention includes the following steps:
[0041] S1. Generate an irrational number using a function matrix and remove the decimal point from the generated irrational number; specifically as follows:
[0042] Such as Figure 2 shown function matrix, that is, horizontally are elementary functions and composite functions of elementary functions, their addition, subtraction, multiplication, and division, and then the horizontal calculation results are obtained. Finally, vertically is the string connection of result 1 to result n, that is, directly connecting the horizontally calculated results. In this embodiment, the symbol "&" is used to represent the string connection operation. That is, the finally obtained irrational number or ultra-large number digital sequence (the decimal point needs to be removed) is:
[0043] Result 1 & Result 2 &...... & Result n.
[0044] From Figure 2It can also be seen that if different x values are taken, this function matrix can calculate different digital sequence results, which is the source and driving force for continuously generating a large number of random numbers. Additionally, the introduction of string concatenation operations can greatly improve the efficiency of digital sequence generation and save the time required for the operation of this algorithm.
[0045] Here, it should be added that the derivative operation and integral operation of elementary functions can also be included in the function matrix operation, and they are advanced operations. Of course, currently, computers cannot directly calculate derivatives and integrals, and people need to calculate the expressions. If the expressions are relatively complex, Taylor series expansion operations may be required.
[0046] When designing the function matrix, it is necessary to estimate the generation results of the function matrix.
[0047] For example, when 100 numbers between 0 and 9 need to be generated, it is actually a 100-digit decimal number. Then the function can be designed as S = (31415926 + x) 20 , because at this time S ≈ (10 7 + x) 20 ≈ 10 140 . This is the most concise. If 200-digit decimal numbers need to be generated, then it can be designed as S = (31415926 + x) 30 , and so on. To enhance randomness, several additional function expressions can be added. Still taking the generation of 100-digit decimal numbers as an example, the function expression can be designed as S = (31415926 + x) 20 + (123456 + 2x) 21 . This is horizontal expansion, and vertical expansion can also be carried out, that is, the calculation results of several horizontal function expressions are connected by string concatenation operations.
[0048] In addition, it should be noted that in the actual programming process, a large function library or Taylor series expansion is required. For example, for the sine function sin(x), if the function library supports the sine function, then the independent variable can be substituted. If there is no support for this function, the function needs to be expanded using the Taylor series and then handed over to the computer for calculation. If the designed function matrix involves advanced operations such as derivatives and integrals, it also needs to be converted into basic addition, subtraction, multiplication, and division expressions first, and then the computer calculates the results.
[0049] In the above, in addition to generating irrational numbers using the function matrix, irrational numbers can also be generated by the construction method; for example, finding prime numbers within 100, that is, 2, 3, 5, 7, 11...... and so on, and then connecting them in sequence to get 235711....., then a very long digital sequence of irrational numbers can be constructed ultimately.
[0050] S2. Next, according to different random number requirements, perform base conversion on the irrational number generated in step S1 to obtain a random number within the range;
[0051] When it is necessary to generate a random integer between 0 and n and n is a positive integer, assume the irrational number n = d0 + 10×d1 + 10 2 ×d2 +......, it is necessary to convert it into a p - base number, that is
[0052] n = c0 + p×c1 + p 2 ×c2 +......, then perform the first base conversion. The specific process of the first base conversion is as follows:
[0053] (1) Judge the relationship between the current integer n and p. If n < p, the conversion ends;
[0054] (2) If n ≥ p, then find the remainder c0, c0 = n % p;
[0055] (3) Perform the operation n'=(n - c0) / p, then get n' = c1 + p×c2 + p 2 ×c3 +......, find c1 by taking the remainder of n', that is c1 = n' % p;
[0056] (4) By analogy, repeat the above method to sequentially obtain the remaining digits, and finally achieve base conversion.
[0057] For example, if it is necessary to generate an integer between [0, 11] with a uniform probability distribution. Then, it can be done like this: First, use a function matrix to generate an irrational number, remove the decimal point to make it an extremely large integer; then, convert this extremely large decimal integer into a 12 - base number. Note that because in a 12 - base number, the digits on the digit positions can only be integers between [0, 11]. That is, when the integer n is divided by 12 to find the remainder, the result can only be an integer between 0 and 11. Therefore, use this feature to convert the base number.
[0058] When it is necessary to generate a random integer between [-m, -n], [-n, m], [-m, n] or [n, m] and n, m are positive integers, m > n, perform the second base conversion. Specifically: By adding or subtracting the upper and lower limits, make the lower limit become 0, that is, convert it to the first base conversion for processing; after the first base conversion is processed, then supplement the number added or subtracted to the upper and lower limits before, and the result is rolled back to the original required range;
[0059] When it is necessary to generate a random number between a and b and a, b are positive decimals, perform the third base conversion. Specifically: First, see which decimal place the random number is required to be accurate to. If the random number is accurate to the 1st decimal place after the decimal point, multiply the upper and lower limits by 10. If the random number is accurate to the 2nd decimal place after the decimal point, multiply the upper and lower limits by 102 , and so on; then perform the conversion according to the binary conversion; after generating a random integer, divide it by the number multiplied before to obtain the random number required originally.
[0060] S3. Extract a part from the irrational number as the encrypted digital string S;
[0061] S4. Perform block processing on the target file;
[0062] S5. Use the numbers in the digital string S to perform encryption operations on each block of file data to obtain ciphertext.
[0063] To prove the effectiveness and superiority of generating random numbers using irrational numbers in the present invention, the present method has been implemented on the Windows platform using the C# programming language below, and preliminary statistics have been performed on the results. The results are as follows:
[0064] As Figure 3 shown, in the digital sequence of nearly three million digits of the irrational number, the occurrence times of each digit are indeed relatively uniform, and this also lays the foundation for this probability algorithm. It should be noted here that the longer the digital sequence, if it is tens of millions of digits or even tens of trillions of digits, the more uniform the occurrence times of each digit will be.
[0065] As Figure 4 shown, for the same function matrix, when the number of generated random numbers is small, the probability uniformity is not obvious. The generated digital length is 361, which can intuitively represent 361 decimal digits. It can be seen that among these hundreds of random numbers, the occurrence probabilities of 0 to 9 are not very uniform.
[0066] As Figure 5 shown, the random numbers generated by the method of the present invention are relatively uniform, and there is no period limit, and a large number of random numbers can be generated.
[0067] As Figure 6 shown, it can be seen that the size of the generated random number exceeds 10 39 . It can be seen that the method of the present invention can generate much larger random numbers than general random number algorithms. In fact, the upper limit of the theoretically generated random numbers in the method of the present invention can be infinitely large.
[0068] The above-described embodiments are only the preferred embodiments of the present invention, and do not limit the scope of implementation of the present invention. Therefore, all changes made according to the shape and principle of the present invention should be covered within the protection scope of the present invention.
Claims
1. An irrational number encryption method, characterized in that, It includes the following steps: S1. Generate an irrational number N without a decimal point; In step S1, the function matrix or the construction method is used to generate an irrational number N without a decimal point; S2. According to different random number requirements, perform a radix conversion on the irrational number N without a decimal point generated in step S1 to obtain a random number within the range; In step S2, when a random integer between 0 and n needs to be generated and n is a positive integer, assuming that N=d0+10×d1+10 2 ×d2+......, it needs to be converted into a p-base number, that is, N=c0+p×c1+p 2 ×c2+......, the conversion is performed according to the first base. The specific process of the first base conversion is as follows: (1) Judge the relationship between the current N and p. If N < p, the conversion ends; (2) If N ≥ p, find the remainder c0, c0 = N % p; (3) Perform the operation N′ = (N - c0) / p, then we get N′ = c1 + p×c2 + p 2 ×c3 +......, to find c1, take the remainder of N′, that is, c1 = N′ % p; (4) And so on, repeat the above method to successively obtain the remaining digits, and finally realize the radix conversion; S3. Extract a part from the irrational number as the encrypted digital string S; S4. Perform a block processing on the target file; S5. Use the numbers in the digital string S to perform an encryption operation on each block of file data to obtain the ciphertext.
2. The irrational number encryption method according to claim 1, wherein The function matrix is composed of multiple functional expressions, and the irrational number is formed by connecting the calculation results of the multiple functional expressions.
3. The irrational number encryption method according to claim 2, characterized in that, When designing the function matrix, it is necessary to estimate the generation result of the function matrix; and in order to enhance randomness, several additional functional expressions are added on the basis of each functional expression.
4. The irrational number encryption method according to claim 1, characterized in that, The generation of the irrational number by using the construction method includes connecting prime numbers within a specified range to form an irrational number.
5. The irrational number encryption method according to claim 1, characterized in that, In step S2, when it is necessary to generate a random integer between [-m, -n], [-n, m], [-m, n] or [n, m] and n, m are positive integers and m > n, a second radix conversion is performed, specifically: by adding or subtracting the upper and lower limits, the lower limit becomes 0, that is, it is converted to the first radix conversion for processing; after the first radix conversion is processed, the numbers added or subtracted from the upper and lower limits before are supplemented back, and the result is rolled back to the original required range; When it is necessary to generate a random number between a and b, where a and b are positive decimals, a ternary conversion is performed. Specifically: First, look at which decimal place the random number is required to be accurate to. If the random number is accurate to 1 decimal place after the decimal point, multiply the upper and lower limits by 10. If the random number is accurate to 2 decimal places after the decimal point, multiply the upper and lower limits by 10 2 , and so on; then perform the conversion according to the binary conversion; when a random integer is generated, divide it by the number multiplied before to obtain the random number required originally.
Citation Information
Patent Citations
Irrational number encryption algorithm
CN109309562A