Method, device and electronic equipment for generating random numbers
By acquiring broadband data and timestamps from terminal devices and using the Pascal's Triangle model to generate random numbers, the problem of insufficient security of pseudo-random random numbers in existing technologies is solved, achieving high security and cost-effective random number generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-22
- Publication Date
- 2026-04-14
AI Technical Summary
Most random numbers generated in existing technologies are pseudo-random and cannot guarantee their security.
By acquiring broadband data and timestamps from terminal devices, random numbers are generated using Pascal's Triangle model. The elements of Pascal's Triangle model are arranged in a regular pattern. The number of layers in the target model is determined based on the broadband data and timestamps, and random numbers are generated based on the number of layers.
It improves the security of random number generation, generates random numbers that are close to true random numbers, is cost-effective, and is suitable for scenarios such as data encryption.
Smart Images

Figure CN115857875B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network technology and security, and more specifically, to a method, apparatus, and electronic device for generating random numbers. Background Technology
[0002] The rapid development of the internet has placed a significant strain on the high concurrency capabilities of internet applications. This has led to the introduction of random number generation based on specific rules as unique identifiers for databases. Random numbers are categorized into three main standards: statistical pseudo-randomness, cryptographically secure pseudo-randomness, and true randomness. Most random number generation methods in the industry only meet the first standard. True randomness can be achieved by meeting all three standards, such as in physical phenomena like dice, coins, and nuclear fission. However, true randomness is too costly and technically challenging. In the software industry, random numbers meeting the second standard offer the best cost-effectiveness and are the most practical approach. Most random numbers generated by related technologies are pseudo-random and cannot guarantee security.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a method, apparatus, and electronic device for generating random numbers, which at least solves the technical problem that most of the random numbers generated in the prior art are pseudo-random numbers and cannot guarantee the security of random numbers.
[0005] According to one aspect of the embodiments of this application, a method for generating random numbers is provided, comprising: in response to a first instruction from a target object, acquiring broadband data and a timestamp of a terminal device; determining the number of layers of a target model based on the broadband data and the timestamp, and determining a target model based on the number of layers, wherein the target model is used to represent the arrangement of binomial coefficients in the form of a target geometric figure, and the arrangement of elements in the target model is regular; generating random numbers based on the target model, wherein the random numbers are used at least for data encryption.
[0006] Optionally, determining the number of layers of the target model based on broadband data and timestamps, and determining the target model based on the number of layers, includes: obtaining the absolute value of the difference between broadband data and timestamps to obtain a first value; determining the number of layers of the target model if the first value meets preset conditions; determining the first value as the number of layers of the target model if the first value does not meet preset conditions; and determining the target model based on the number of layers of the target model.
[0007] Optionally, if the first value meets the preset conditions, the number of layers of the target model is determined, including: obtaining the first digit of the broadband data to obtain the second value; obtaining the first digit of the timestamp to obtain the third value; and determining the number of layers of the target model based on the product of the second value and the third value.
[0008] Optionally, generating random numbers based on the target model includes: arbitrarily selecting a value from the target model as a coefficient; determining the sum of all numbers in the target model to obtain a fourth value; if the value corresponding to the layer number of the target model is greater than a preset value, taking the first digit of the value corresponding to the layer number of the target model as a fifth value; determining the sum of the numbers in the target model corresponding to the layer number of the fifth value based on the fifth value to obtain a sixth value; and determining a random number based on the fourth value, the coefficient, and the sixth value.
[0009] Optionally, the random number is determined based on the fourth value, the coefficient, and the sixth value, including: determining the seventh value based on the sixth value and the coefficient; and determining the random number based on the absolute value of the difference between the seventh value and the fourth value.
[0010] Optionally, the method further includes: determining the last digit of the broadband data as the eighth value and the last digit of the timestamp as the ninth value; comparing the eighth value and the ninth value to obtain a comparison result; and determining the smaller of the comparison results as the coefficient.
[0011] Optionally, the method further includes: when the last digit of the broadband data is 0, determining the non-zero digit preceding the last digit of the broadband data as the eighth value; when the last digit of the timestamp is 0, determining the non-zero digit preceding the last digit of the timestamp as the ninth value.
[0012] According to another aspect of the embodiments of this application, a random number generation apparatus is also provided, comprising: an acquisition module, configured to acquire broadband data and a timestamp of a terminal device in response to a first instruction from a target object; a determination module, configured to determine the number of layers of a target model based on the broadband data and the timestamp, and to determine the target model based on the number of layers, wherein the target model is used to represent the arrangement of binomial coefficients in the form of a target geometric figure; and a generation module, configured to generate random numbers based on the target model, wherein the random numbers are used at least for data encryption.
[0013] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory for storing program instructions; and a processor connected to the memory for executing program instructions to perform the following functions: in response to a first instruction of a target object, acquiring broadband data and a timestamp of a terminal device; determining the number of layers of a target model based on the broadband data and the timestamp, and determining the target model based on the number of layers, wherein the target model is used to represent the arrangement of binomial coefficients in the form of a target geometry; and generating random numbers based on the target model, wherein the random numbers are used at least for data encryption.
[0014] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-described random number generation method by running the computer program.
[0015] In this embodiment, by responding to a first instruction from the target object, broadband data and timestamps of the terminal device are obtained; the number of layers of the target model is determined based on the broadband data and timestamps, and the target model is determined based on the number of layers, wherein the target model is used to represent the arrangement of binomial coefficients in the form of a target geometric figure; random numbers are generated based on the target model, wherein the random numbers are used at least for data encryption, thereby achieving the purpose of determining the number of layers of the target model based on the broadband data and timestamps of the terminal device, thereby achieving the technical effect of improving the security of random number generation, and thus solving the technical problem that most of the random numbers generated in the prior art are pseudo-random random numbers, which cannot guarantee the security of random numbers. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0017] Figure 1 This is a hardware structure block diagram of a computer terminal (or electronic device) for implementing a method for generating random numbers according to an embodiment of this application;
[0018] Figure 2 This is a flowchart of a random number generation method according to an embodiment of this application;
[0019] Figure 3 This is a structural diagram of a random number generation apparatus according to an embodiment of this application;
[0020] Figure 4a This is a flowchart of an algorithm for generating random numbers according to an embodiment of this application;
[0021] Figure 4bThis is a schematic diagram of a Pascal's triangle model according to an embodiment of this application. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0024] The random number generation method provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or electronic device) for implementing a method for generating random numbers is shown. Figure 1 As shown, the computer terminal 10 (or electronic device 10) may include one or more processors (shown as 102a, 102b, ..., 102n in the figure) (the processor may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0025] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be wholly or partially embodied in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuit may be a single, independent processing module, or may be wholly or partially integrated into any other element within the computer terminal 10 (or electronic device). As involved in the embodiments of this application, the data processing circuit serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0026] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the random number generation method in this embodiment. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-mentioned random number generation method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0027] The transmission module 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission module 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0028] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or electronic device).
[0029] It should be noted here that, in some optional embodiments, the above... Figure 1 The computer device (or electronic device) shown may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that... Figure 1This is only one instance of a particular specific instance, and is intended to illustrate the types of components that may exist in the aforementioned computer equipment (or electronic equipment).
[0030] In the above operating environment, this application provides an embodiment of a method for generating random numbers. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0031] Figure 2 This is a flowchart of a random number generation method according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:
[0032] Step S202: In response to the first instruction from the target object, obtain the broadband data and timestamp of the terminal device;
[0033] Step S204: Determine the number of layers of the target model based on broadband data and timestamps, and determine the target model based on the number of layers. The target model is used to represent the binomial coefficients arranged in the form of a target geometric figure. The arrangement of elements in the target model is regular.
[0034] Step S206: Generate random numbers based on the target model, wherein the random numbers are used at least for data encryption.
[0035] In steps S202 to S206 above, the target model can be, for example, Pascal's Triangle. Pascal's Triangle is a geometric arrangement of binomial coefficients within a triangle. It graphically represents the binomial coefficients and visually illustrates some inherent algebraic properties of combinations, representing a discrete combination of numbers and shapes. This application's embodiment introduces Pascal's Triangle model. By obtaining broadband data and timestamps from the terminal device (i.e., the local machine), and inputting these into Pascal's Triangle model to obtain random numbers, it can solve the technical problem in related technologies where the security of random numbers cannot be guaranteed.
[0036] In step S204 of the above random number generation method, the number of layers of the target model is determined based on the broadband data and the timestamp, and the target model is determined based on the number of layers. Specifically, this includes the following steps: obtaining the absolute value of the difference between the broadband data and the timestamp to obtain a first value; determining the number of layers of the target model if the first value meets a preset condition; determining the first value as the number of layers of the target model if the first value does not meet the preset condition; and determining the target model based on the number of layers of the target model.
[0037] In this embodiment of the application, the physical bandwidth traffic (i.e., the bandwidth data mentioned above) of the local machine (i.e., the terminal device) during program execution and the timestamp of the local machine when the program is executed are obtained by means of a programming language. Both the bandwidth traffic and the timestamp are positive integers.
[0038] The absolute value obtained by subtracting the timestamp value from the bandwidth traffic value is used to obtain a first value. It is then determined whether the first value meets a preset condition. Specifically, it is determined whether the first value is 0. If it is 0, the first value is considered to meet the preset condition. At this time, the bandwidth traffic value and the timestamp value are the same, and the number of layers of the target model needs to be further determined. If the first value is not 0, the first value is considered not to meet the preset condition. At this time, the first value is the number of layers of the target model (Pascal's Triangle model in this embodiment). Then, Pascal's Triangle model is determined based on the number of layers, and the data in Pascal's Triangle model is determined.
[0039] In the above steps, if the first value meets the preset conditions, the number of layers of the target model is determined, which specifically includes the following steps: obtaining the first digit of the broadband data to obtain the second value; obtaining the first digit of the timestamp to obtain the third value; and determining the number of layers of the target model based on the product of the second value and the third value.
[0040] In this embodiment, when the first value is 0, it is necessary to further obtain the number of layers in the target model. Specifically, the first digit of the broadband traffic value is used as the second value, and the first digit of the timestamp value is used as the third value. The product of the second and third values is taken as the number of layers n in the target model. The following example illustrates this: when both the broadband traffic value and the timestamp value are 54321, the absolute value obtained by subtracting the timestamp value from the broadband traffic value is 0. In this case, the first digit 5 of the broadband traffic value is obtained as the second value, and the first digit 5 of the timestamp value is obtained as the third value. 5*5=25 is taken as the number of layers n in the target model. Since the number of layers in Pascal's Triangle model is fixed, once the number of layers in the target model (i.e., Pascal's Triangle model) is determined, the target model can be generated.
[0041] In step S206 of the above-mentioned random number generation method, generating random numbers based on the target model specifically includes the following steps: arbitrarily selecting a value from the target model as a coefficient; determining the sum of all numbers in the target model to obtain a fourth value; if the value corresponding to the layer number of the target model is greater than a preset value, taking the first digit of the value corresponding to the layer number of the target model as a fifth value; determining the sum of the numbers in the target model corresponding to the fifth value based on the fifth value to obtain a sixth value; and determining a random number based on the fourth value, the coefficient, and the sixth value.
[0042] In this embodiment, after determining the Pascal's Triangle model, a value is randomly selected from the Pascal's Triangle model as a coefficient. Since the Pascal's Triangle model was previously determined based on the number of layers n, when determining the sum of all numbers in the target model, that is, calculating the sum of the numbers in the first n rows of Pascal's Triangle, the fourth value can be obtained according to the formula [(1+n)n] / 2. It should be noted that if the value corresponding to the number of layers in the target model is greater than the preset value, for example, when the broadband traffic value is 1654642136 and the timestamp value is 1654607515, n = 34621 is obtained according to the above calculation process, and the fourth value is [(1+n)n] / 2 = 599324131. At this time, n is 34621, which is greater than the preset value of 50. The preset value can be set according to the actual situation. The setting of 50 here is only for illustrative purposes and does not mean limitation. In the above example, the first digit 3 of 34621 is taken as the fifth value, according to formula 2. n-1 To determine the sum of the numbers in the nth layer, substitute n=3 into the formula above. The sum of the numbers in the 3rd layer is 4, which is also the sixth value of 4. Based on the fourth value 599324131, the randomly selected coefficients in the target model, and the sixth value 4, determine a random number.
[0043] In another optional embodiment, if the preset value is set to 50, when the number of layers n is greater than 50, the first two digits of n can be taken as the fifth value, and then according to 2 n-1 Determine the sum of the numbers in the layer containing the fifth value. If the sum of the first two digits of n is still greater than the preset value of 50, then use 50 as the final fifth value.
[0044] In the above steps, the random number is determined based on the fourth value, the coefficient, and the sixth value, specifically including the following steps: determine the seventh value based on the sixth value and the coefficient; determine the random number based on the absolute value of the difference between the seventh value and the fourth value.
[0045] In this embodiment of the application, if the value of the coefficient is randomly selected as 5, the seventh value is determined to be 20 based on the product of the sixth value 4 and the coefficient 5. The absolute value of the difference between the seventh value and the fourth value is determined as a random number, that is, the final random number is |20-599324131|=599324111.
[0046] The method for generating random numbers described above further includes the following steps: determining the last digit of the broadband data as the eighth value and the last digit of the timestamp as the ninth value; comparing the eighth value and the ninth value to obtain a comparison result; and determining the smaller of the comparison results as the coefficient.
[0047] In this embodiment of the application, the coefficient can also be determined by another method, as follows: when the value of broadband traffic is 1654642136 and the value of timestamp is 1654607515, take the last digit of broadband traffic, 6, as the eighth value, take the last digit of timestamp, 5, as the ninth value, and take the smaller of the eighth value and the ninth value as the coefficient, that is, the coefficient is 5.
[0048] In the above method for generating random numbers, the method further includes the following steps: when the last digit of the broadband data is 0, the non-zero digit preceding the last digit of the broadband data is determined as the eighth value; when the last digit of the timestamp is 0, the non-zero digit preceding the last digit of the timestamp is determined as the ninth value.
[0049] In this embodiment of the application, since the coefficient cannot be 0, when the last digit of the broadband traffic or the last digit of the timestamp is 0, one digit is added forward. The non-zero data before the last digit of the broadband traffic is determined as the eighth value, and the non-zero data before the last digit of the timestamp is determined as the ninth value. Then, the comparison operation between the eighth value and the ninth value is performed.
[0050] The random number generation method provided in this application has the following advantages: 1. It can generate random numbers with security attributes. The random number generation method in this application obtains the local bandwidth data and timestamp, and obtains the layer number of Pascal's Triangle model according to certain calculation rules, effectively ensuring the security of the random numbers. 2. It is infinitely close to true random numbers. The local bandwidth data (such as bandwidth traffic data) is physically random, and together with multiple random values such as physical time, it forms a random number with extremely high randomness. 3. It has a high cost-performance ratio. The random number generation method provided in this application uses traditional software algorithms to simulate extremely high randomness, which can cover almost 100% of the random number usage scenarios in the current industry. 4. The program is simple and compact, and easier to deploy.
[0051] The random number generation method provided in this application combines traditional random number generation methods in the industry with the Pascal's triangle model and its various mathematical properties, which greatly increases the randomness of the random numbers, making them infinitely close to true random numbers. Furthermore, the acquisition of physical bandwidth traffic and physical timestamps is more random. This algorithm generates random numbers comparable to true random numbers with a simple algorithm, and has extremely high cost performance.
[0052] The random number generation method provided in this application can, for example, be applied to user preference settings data in an anti-harassment platform. The primary key generation of user order data uses the aforementioned random number generation method, ensuring uniqueness. Furthermore, the aforementioned random number generation method can also be applied to the generation of encryption keys for certain interfaces, providing better security.
[0053] Figure 3 This is a structural diagram of a random number generation apparatus according to an embodiment of this application, such as... Figure 3 As shown, the device includes:
[0054] The acquisition module 302 is used to acquire the broadband data and timestamp of the terminal device in response to the first instruction of the target object;
[0055] The determination module 304 is used to determine the number of layers of the target model based on broadband data and timestamps, and to determine the target model based on the number of layers. The target model is used to represent the binomial coefficients arranged in the form of a target geometric figure, and the arrangement of elements in the target model is regular.
[0056] The generation module 306 is used to generate random numbers based on the target model, wherein the random numbers are used at least for data encryption.
[0057] In the determination module of the above-mentioned random number generation device, the number of layers of the target model is determined based on the broadband data and the timestamp, and the target model is determined based on the number of layers. Specifically, the process includes the following steps: obtaining the absolute value of the difference between the broadband data and the timestamp to obtain a first value; determining the number of layers of the target model if the first value meets a preset condition; determining the first value as the number of layers of the target model if the first value does not meet the preset condition; and determining the target model based on the number of layers of the target model.
[0058] In the determination module of the above-mentioned random number generation device, when the first value meets the preset conditions, the number of layers of the target model is determined, which specifically includes the following process: obtaining the first digit of the broadband data to obtain the second value; obtaining the first digit of the timestamp to obtain the third value; and determining the number of layers of the target model based on the product of the second value and the third value.
[0059] In the generation module of the aforementioned random number generation device, the random number is generated based on the target model, specifically including the following process: arbitrarily selecting a value from the target model as a coefficient; determining the sum of all numbers in the target model to obtain a fourth value; if the value corresponding to the layer number of the target model is greater than a preset value, taking the first digit of the value corresponding to the layer number of the target model as a fifth value; determining the sum of the numbers in the target model corresponding to the fifth value at the layer number corresponding to the fifth value to obtain a sixth value; and determining a random number based on the fourth value, the coefficient, and the sixth value.
[0060] In the generation module of the aforementioned random number generation device, a random number is determined based on the fourth value, the coefficient, and the sixth value. Specifically, the process includes the following steps: determining the seventh value based on the sixth value and the coefficient; and determining the random number based on the absolute value of the difference between the seventh value and the fourth value.
[0061] In the determination module of the above-mentioned random number generation device, the determination module is further used to determine the last digit of the broadband data as the eighth value and the last digit of the timestamp as the ninth value; compare the eighth value and the ninth value to obtain a comparison result; and determine the smaller of the comparison results as the coefficient.
[0062] In the determination module of the above-mentioned random number generation device, the determination module is further used to determine the non-zero data preceding the last data of the broadband data as the eighth value when the last data of the broadband data is 0; and to determine the non-zero data preceding the last data of the timestamp as the ninth value when the last data of the timestamp is 0.
[0063] It should be noted that, Figure 3 The random number generator shown is used to perform... Figure 2 The method for generating random numbers shown above also applies to the random number generating device, and will not be repeated here.
[0064] Figure 4a This is a flowchart of an algorithm for generating random numbers according to an embodiment of this application, such as... Figure 4a As shown, first, the bandwidth traffic value and timestamp of the currently running host are obtained. For example, if the bandwidth traffic is 1654642136B and the timestamp is 1654607515, the absolute value of the difference between the bandwidth traffic and the timestamp is taken. If the resulting value is not 0, it is used as the layer number n. In the example above, n = |bandwidth traffic - timestamp| = 34621. Therefore, n is not 0, meaning the layer number n = 34621. In another case, if the absolute value of the difference between the bandwidth traffic and the timestamp is 0, the product of the first digit of the bandwidth traffic value and the first digit of the timestamp is taken as the layer number n. After obtaining the layer number n, a Pascal's Triangle model is created based on the parameter n. For example, a Pascal's Triangle model can be created as follows: Figure 4b As shown, Figure 4b The data included in Pascal's Triangle model are only listed when n=10. The data included in Pascal's Triangle model are different when n takes different values, and they are not listed here.
[0065] Obtain the last two digits of the broadband traffic data and the last two digits of the timestamp as two random numbers. The last two digits of the broadband traffic data are represented by the eighth value mentioned above, and the last two digits of the timestamp are represented by the ninth value mentioned above. Select the smaller of these two random numbers as the coefficient. Specifically, in the case of broadband traffic data of 1654642136B and timestamp data of 1654607515, the eighth value (random number 1) is 6, and the ninth value (random number 2) is 5. The smaller of these two values is used as the coefficient, resulting in a coefficient of 5. It should be noted that if the last two digits are 0 (i.e., the eighth or ninth value is 0), add one digit to the left, and use the data that is not 0 at the end as the eighth or ninth value. To calculate the sum of the first n rows and the sum of the nth row of Pascal's Triangle, specifically, taking n = 34621 as an example, the sum of the first n rows can be calculated using the formula [(1+n)n] / 2 to obtain 599324131. When calculating the sum of the nth row, since n = 34621 is greater than the preset value of 50, this preset value can be set according to the actual situation. The setting of 50 here is only for illustrative purposes and does not represent a limitation. Therefore, to reduce the amount of calculation, the first digit 3 of n = 34621 is taken as n for calculating the sum of the nth row, that is, the sum of the nth row (n = 3) is calculated using formula 2. n-1 The value is determined to be 4. Multiply the sum of the numbers in the nth row by the coefficient, then subtract the sum of the numbers in the first n rows and take the absolute value. This is the final random number. Specifically, the final random number = |4*5 - 599324131| = 599324111.
[0066] This application embodiment also provides a non-volatile storage medium, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the following random number generation method by running the computer program: in response to a first instruction from a target object, acquiring broadband data and a timestamp of a terminal device; determining the number of layers of a target model based on the broadband data and the timestamp, and determining the target model based on the number of layers, wherein the target model is used to represent the arrangement of binomial coefficients in the form of a target geometric figure; generating random numbers based on the target model, wherein the random numbers are used at least for data encryption.
[0067] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0068] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0069] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0070] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0071] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0072] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0073] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for generating random numbers, characterized in that, include: In response to the first instruction from the target object, obtain the broadband data and timestamp of the terminal device; The number of layers of the target model is determined based on the broadband data and the timestamp, and the target model is determined based on the number of layers, wherein the target model is used to represent the binomial coefficients arranged in the form of a target geometric figure; Random numbers are generated based on the target model, wherein the random numbers are used at least for data encryption; Determining the number of layers of a target model based on the broadband data and the timestamp, and determining the target model based on the number of layers, includes: obtaining the absolute value of the difference between the broadband data and the timestamp to obtain a first value; determining the number of layers of the target model if the first value satisfies a preset condition; determining the first value as the number of layers of the target model if the first value does not satisfy the preset condition; and determining the target model based on the number of layers of the target model. If the first value meets a preset condition, the number of layers of the target model is determined, including: obtaining the first digit of the broadband data to obtain a second value; obtaining the first digit of the timestamp to obtain a third value; and determining the number of layers of the target model based on the product of the second value and the third value. Generating random numbers based on the target model includes: arbitrarily selecting a value from the target model as a coefficient; determining the sum of all numbers in the target model to obtain a fourth value; if the value corresponding to the layer number of the target model is greater than a preset value, taking the first digit of the value corresponding to the layer number of the target model as a fifth value; determining the sum of the numbers in the target model corresponding to the fifth value based on the fifth value to obtain a sixth value; determining a seventh value based on the sixth value and the coefficient; and determining the random number based on the absolute value of the difference between the seventh value and the fourth value.
2. The method according to claim 1, characterized in that, The method further includes: The last digit of the broadband data is determined as the eighth value, and the last digit of the timestamp is determined as the ninth value. Compare the eighth value and the ninth value to obtain the comparison result; The smaller of the comparison results is determined as the coefficient.
3. The method according to claim 2, characterized in that, The method further includes: When the last digit of the broadband data is 0, the non-zero digit preceding the last digit of the broadband data is determined as the eighth value. When the last digit of the timestamp is 0, the non-zero digit preceding the last digit of the timestamp is determined as the ninth value.
4. A random number generation device, characterized in that, include: The acquisition module is used to acquire the broadband data and timestamp of the terminal device in response to the first instruction from the target object; A determining module is configured to determine the number of layers of a target model based on the broadband data and the timestamp, and to determine the target model based on the number of layers, wherein the target model represents a binomial coefficient arranged in the form of a target geometric figure; determining the number of layers of the target model based on the broadband data and the timestamp, and to determine the target model based on the number of layers, includes: obtaining the absolute value of the difference between the broadband data and the timestamp to obtain a first value; determining the number of layers of the target model if the first value satisfies a preset condition; determining the first value as the number of layers of the target model if the first value does not satisfy the preset condition; determining the target model based on the number of layers of the target model; determining the number of layers of the target model if the first value satisfies a preset condition, includes: obtaining the first digit corresponding to the broadband data to obtain a second value; obtaining the first digit corresponding to the timestamp to obtain a third value; and determining the number of layers of the target model based on the product of the second value and the third value. A generation module is used to generate random numbers based on the target model, wherein the random numbers are used for at least data encryption. Generating random numbers based on the target model includes: arbitrarily selecting a value from the target model as a coefficient; determining the sum of all numbers in the target model to obtain a fourth value; if the value corresponding to a layer number in the target model is greater than a preset value, taking the first digit of the value corresponding to the layer number in the target model as a fifth value; determining the sum of the numbers in the target model corresponding to the fifth value in the layer to obtain a sixth value; determining a seventh value based on the sixth value and the coefficient; and determining the random number based on the absolute value of the difference between the seventh value and the fourth value.
5. An electronic device, characterized in that, include: Memory, used to store program instructions; A processor, connected to the memory, is configured to execute program instructions that perform the following functions: In response to a first instruction from a target object, acquiring broadband data and a timestamp from a terminal device; determining the number of layers of a target model based on the broadband data and the timestamp, and determining the target model based on the number of layers, wherein the target model represents a binomial coefficient arranged in the form of a target geometric figure; generating random numbers based on the target model, wherein the random numbers are used at least for data encryption; determining the number of layers of the target model based on the broadband data and the timestamp, and determining the target model based on the number of layers, includes: acquiring the absolute value of the difference between the broadband data and the timestamp to obtain a first value; determining the number of layers of the target model if the first value satisfies a preset condition; determining the number of layers of the target model if the first value does not satisfy the preset condition; and determining the number of layers of the target model based on the number of layers of the target model. The target model; under the condition that the first value satisfies a preset condition, determining the number of layers of the target model includes: obtaining the first digit of the broadband data to obtain a second value; obtaining the first digit of the timestamp to obtain a third value; determining the number of layers of the target model based on the product of the second value and the third value; generating a random number based on the target model includes: arbitrarily selecting a value from the target model as a coefficient; determining the sum of all numbers in the target model to obtain a fourth value; if the value corresponding to the number of layers of the target model is greater than a preset value, taking the first digit of the value corresponding to the number of layers of the target model as a fifth value; determining the sum of the numbers of the target model at the number of layers corresponding to the fifth value based on the fifth value to obtain a sixth value; determining a seventh value based on the sixth value and the coefficient; and determining the random number based on the absolute value of the difference between the seventh value and the fourth value.
6. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the random number generation method according to any one of claims 1 to 3 by running the computer program.
Citation Information
Patent Citations
Network voice conversation detecting flow generation method based on conversation model
CN101051960A
Data packet generator for generating passcodes
CN102165460A