Irrational number encryption method
Through the irrational number generation method, the period and size limitations of the pseudo-random number algorithm are solved, and the random number generation without period and size limitations are realized, which improves the security and flexibility of data encryption.
Patent Information
- Application Number
- CN202510829331.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-27
- Publication Date
- 2025-08-01
AI Technical Summary
The pseudo-random number generation algorithms in the prior art have periodic and size limitations, which are difficult to meet the encryption requirements of no periodic and no size limitations in modern network security.
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 periodic limits, are highly flexible, and can generate large numbers with an approximate length of infinite, which is suitable for various encryption algorithms and improve data transmission security.
Smart Images

Figure CN120408683A_ABST
Abstract
Description
[0001] This application is a divisional application. The original application's invention title is "An Irrational Number Encryption Method", with the application number 202110461552.2 and the application date being April 27, 2021. Technical Field
[0002] The present invention relates to the technical fields of data encryption and random number generation, and particularly to an irrational number encryption method. Background Art
[0003] With the development of society, technology has been 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 leaks, the network information security problems have seriously hindered 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.
[0004] 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 encrypt specific computer files, it will be beneficial to improve the security of data encryption. Summary of the Invention
[0005] The purpose of the present invention is to provide a random number generation method without period limitations, without size limitations, and with high flexibility, and apply it to the irrational number encryption method.
[0006] To achieve the above purpose, the technical solution provided by the present invention is as follows:
[0007] An irrational number encryption method, comprising the following steps:
[0008] S1. Generate an irrational number after removing the decimal point;
[0009] S2. According to different random number requirements, perform base conversion on the irrational number generated in step S1 after removing the decimal point to obtain random numbers within the range;
[0010] In programming, it is necessary to read a file byte by byte, and the data content of one byte ranges from 0 to 255. If the encrypted digital string S always takes decimal numbers, that is, numbers between 0 and 9, then the encryption will not be complete. If the original decimal encrypted digital string S is converted to a 256 - base system, then each digit in S at this time is also between 0 and 255, and in this way, complete encryption of computer files byte by byte can be achieved. Therefore, the conversion of irrational - number bases is particularly important.
[0011] S3. Extract a part from the irrational number as the encrypted digital string S;
[0012] S4. Process the target file in blocks;
[0013] S5. Use the numbers in the digital string S to encrypt each block of file data to obtain ciphertext.
[0014] Further, in step S1, the irrational number is generated by using a function matrix or the construction method.
[0015] Further, the function matrix is composed of multiple function expressions, and the irrational number is formed by connecting the calculation results of these multiple function expressions.
[0016] Further, when designing the function matrix, it is necessary to estimate the generation result of the function matrix; and in order to enhance randomness, based on each function expression, several additional function expressions are added.
[0017] Further, the generation of the irrational number by using the construction method includes connecting prime numbers within a specified range to form an irrational number.
[0018] Further, in step S2, when it is necessary to generate a random integer between 0 and n and n is a positive integer, assuming the irrational number n = d0 + 10×d1 + 10 2 ×d2 + ……, it needs to be converted to a p - base number, that is, n = c0 + p×c1 + p2×c2 + ……, then the first - base conversion is carried out, and the specific process of the first - base conversion is as follows:
[0019] (1) Judge the relationship between the current integer n and p. If n < p, the conversion ends;
[0020] (2) If n ≥ p, then find the remainder c0, c0 = n % p;
[0021] (3) Perform the operation n′=(n - c0) / p, then n′ = c1 + p×c2 + p 2 ×c3 +......, find c1 by taking the remainder of n′, that is, c1 = n′ % p;
[0022] (4) And so on, repeat the above method to obtain the remaining digits in turn, and finally achieve the radix conversion.
[0023] 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, 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 is changed to 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 previous upper and lower limits are supplemented back, and the result is rolled back to the original required range;
[0024] When it is necessary to generate a random number between a and b and a, b are positive decimals, a third radix conversion is performed. Specifically: first, see 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 second radix conversion; when a random integer is generated, divide it by the number multiplied before to obtain the random number required originally.
[0025] Compared with the prior art, the principles and advantages of this solution are as follows:
[0026] 1. Compared with the pseudo-random numbers relied on by traditional algorithms, which have certain period limitations, the pseudo-random numbers generated by this solution using irrational numbers have no period limitations and can be approximated infinitely as long as there are sufficient resources.
[0027] 2. Compared with the pseudo-random numbers generated by traditional algorithms, which 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.
[0028] 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.
[0029] 4. With the support of computing power, the function matrix can theoretically be calculated infinitely in this solution, and as the number of generated random numbers increases, the occurrence times will be more uniform.
[0030] 5. The random numbers generated by this solution are calculated in real time and can be reproduced, without the need to be calculated in advance and occupy additional storage space.
[0031] 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.
[0032] 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. Since encryption algorithms require a certain degree of randomness 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. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the services required in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0034] Figure 1 is a principle flowchart of an irrational number encryption method of the present invention;
[0035] Figure 2 is a schematic diagram of the function matrix in the embodiment;
[0036] Figure 3 is a statistical result chart of the occurrence times of each digit (i.e., 0 to 9) in an irrational number digital sequence containing a large number of digits;
[0037] Figure 4 is a schematic diagram of probability uniformity;
[0038] Figure 5 is a statistical result chart of random numbers generated in the range of [0, 20];
[0039] Figure 6 is a computer test diagram for generating extremely large random numbers. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0040] The present invention will be further described below in conjunction with specific embodiments:
[0041] As Figure 1 shown, an irrational number encryption method described in an embodiment of the present invention includes the following steps:
[0042] S1. Generate an irrational number using a function matrix and remove the decimal point from the generated irrational number; specifically as follows:
[0043] As Figure 2The function matrix shown, where 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 concatenation of Result 1 to Result n, that is, directly concatenating the horizontally calculated results. In this embodiment, the symbol "&" is used to represent the string concatenation operation. That is, the resulting irrational number or super-large number digital sequence (the decimal point needs to be removed) is:
[0044] Result 1 & Result 2 &...... & Result n.
[0045] From Figure 2 It can also be seen that if different x values are taken, then this function matrix can calculate different digital sequence results, which is the source and motivation for continuously generating a large number of random numbers. In addition, the introduction of the string concatenation operation can greatly improve the efficiency of digital sequence generation and save the time required for the operation of this algorithm.
[0046] It should be added here 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.
[0047] When designing the function matrix, it is necessary to estimate the generation results of the function matrix.
[0048] 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 terms can be added. Still taking the generation of 100-digit decimal numbers as an example, the function can be designed as S = (31415926 + x) 20 + (123456 + 2x) 21 . This is horizontal expansion, and vertical expansion can also be done, that is, connecting the calculation results of several horizontal function expressions with string concatenation operations.
[0049] 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 just substitute the independent variable. If there is no such function support, it is necessary to expand the function using the Taylor series and then let the computer perform the calculation. If the designed function matrix involves advanced operations such as differentiation and integration, it is also necessary to first convert them into basic addition, subtraction, multiplication, and division expressions and then let the computer calculate the results.
[0050] 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, to find prime numbers within 100, that is, 2, 3, 5, 7, 11...... and so on, and then connect them in sequence to get 235711....., then ultimately a very long sequence of irrational number digits can be constructed.
[0051] S2. Next, according to different random number requirements, perform a base conversion on the irrational numbers generated in step S1 to obtain random numbers within the range;
[0052] When a random integer between 0 and n is required 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, 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 the base conversion.
[0057] For example, if it is required to generate integers between [0, 11] with a uniform probability distribution. Then, it can be done as follows: 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 integer in decimal to a number in base 12. Note that since in a number in base 12, the digits in each digit position can only be integers between [0, 11]. That is, when the integer n is divided by 12, the result can only be an integer between 0 and 11. Therefore, this characteristic is used to convert the number system.
[0058] When it is required to generate random integers between [-m, -n], [-n, m], [-m, n] or [n, m] where n and m are positive integers and m > n, a second number system conversion is performed. Specifically: By adding or subtracting the upper and lower limits, the lower limit is made 0, that is, it is converted to the first number system conversion for processing; after the first number system conversion is processed, the numbers added or subtracted to the upper and lower limits before are supplemented back, and the result is reverted to the range required originally;
[0059] When it is required to generate a random number between a and b where a and b are positive decimals, a third number system conversion is performed. Specifically: First, see to which decimal place the random number is required to be accurate. If the random number is accurate to 1 decimal place after the decimal point, then multiply the upper and lower limits by 10. If the random number is accurate to 2 decimal places after the decimal point, then multiply the upper and lower limits by 10 2 , and so on; then perform the conversion according to the second number system 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 a block processing on the target file;
[0062] S5. Use the numbers in the digital string S to perform an encryption operation on each block of file data to obtain the ciphertext.
[0063] To prove the effectiveness and superiority of generating random numbers using irrational numbers in the present invention, the present method is implemented on the Windows platform using the C# programming language below, and a preliminary statistic is performed on the results. The results are as follows:
[0064] As Figure 3 shown, in a digital sequence of an irrational number of nearly three million digits, 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, then the occurrence times of each digit will be more uniform.
[0065] As Figure 4As shown, for the same function matrix, when the number of generated random numbers is small, the probability uniformity is not obvious. The length of the generated numbers 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 numbers 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 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 the step S2, when a random integer between 0 and n is required and n is a positive integer, assuming N = d0 + 10×d1 + 10 2 ×d2 +......, it is necessary to convert it into a p - base number, that is, N = c0 + p×c1 + p 2 ×c2 +......, then the first base conversion is carried out. 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' with respect to p, that is, c1 = N' % p; (4) And so on, repeat the above method to sequentially obtain the remaining digits, and finally realize the radix conversion; 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 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 range required originally; 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 needs to be accurate to. If the random number is accurate to the first decimal place, multiply the upper and lower limits by 10. If the random number is accurate to the second decimal place, 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; S3. Extract part of 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.