Method and device for generating random numbers
Abstract
The invention discloses a method and a device for generating random numbers and belongs to the field of computers. The method includes: acquiring sound of the external environment, converting the acquired sound into a first digital signal, and generating the random numbers according to the first digital signal. The device comprises a conversion module and a generation module. By the method and the device for generating the random numbers, cost for generating the random numbers can be reduced, and randomness of the generated random numbers can be improved.
Term
No projected expiry on record.
- Priority and filed
- Published
- Today
13 claims: 2 independent, 11 dependent
- 1generating a random number the method wherein said method comprises:Collecting external environment in the audio the gathered sound is converted into first digital signal;According to said first digital signal generating a random number. 1.一种生成随机数的方法,其特征在于,所述方法包括: 采集外界环境内的声音,将采集的声音转换为第一数字信号; 根据所述第一数字信号生成随机数。
- 7random number generating device wherein said device comprises:Conversion module is used for collecting external environment in the audio the gathered sound is converted into first digital signal;Generating module is used for according to said first digital signal generating a random number. 7.—种生成随机数的装置,其特征在于,所述装置包括: 转换模块,用于采集外界环境内的声音,将采集的声音转换为第一数字信号; 生成模块,用于根据所述第一数字信号生成随机数。
Independent claims2
163 paragraphs, as filed
The technical field of
[0001] the invention claims computer field especially claims a generating a random number method and device for.
Background technology
[0002] random number in the computer system has important application such as in order to keep the certain information of the privacy of user need to the information is encrypted and the information secrecy capability is determined by the key the key is composed of random number generated by the generated random number the method of the present widely attention this utility model solves the problem of one.
[0003] present generating a random number the method is specifically: The random number generating circuit is connected with the computer parallel port the random number generating circuit comprises a white noise generator circuit and amplifier circuit. White noise generator circuit generates an analog noise signal of said analog noise signal through amplifying circuit is converted into digital noise signal according to the digital noise signal of generating a random number.
At ] [ 0004 to realize the invention in the process of inventor found that present technology at least following problems:
[0005] existing technology needs to provide extra random number generating circuit is connected with the computer parallel port of the random number generating circuit needs to use of the computer parallel port data pin of power supply there is no need to computer software to do to and present technology generating a random number random low.
The content of invention
[0006] in order to solve the problems of the existing technique the embodiment of this invention claims a generating a random number method and device for. Said technology plan is as follows:
[0007] a first aspect the invention claims a generating a random number the method of said method comprises:
[0008] collecting external environment in the audio the gathered sound is converted into first digital signal;
[0009] according to said first digital signal generating a random number.
[0010] is combined with a first aspect in a first aspect a first possible realizing method in the rice collecting the sound is converted into first digital signal comprises:
[0011] according to the sampling frequency and sampling time length of the collected sound sampling to obtain the sampling signal;
[0012] according to sampling digit to the said sampling signal to perform quantization to obtain quantized signal;
[0013] to the quantized signal coding to get the first digital signal.
[0014] is combined with a first aspect in a first aspect of the second possible realizing method in said according to said first digital signal generating a random number comprises:
[0015] the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal;
[0016] the second digital signal carrying out hash calculation and the hash operation result is determined to be random number.
[0017] is combined with a first aspect a first possible realizing method in a first aspect of the third the implementation mode according to the sampling frequency and sampling time length of the collected sound to sample before it also comprises:
[0018] is set with sampling frequency sampling digit and sampling time.
[0019] the first side or the one side of the first and the function of realizing method to the one side of the third can realizing mode in any possible realizing method in a first aspect of the fourth possible realizing method in said the first digital signal and the stored random number to be connected in series before it also comprises:
[0020] is used for receiving user input end of the random number and storing the received random number.
[0021] the first side or the one side of the first and the function of realizing method to the one side of the fourth possible realizing method in any possible realizing method in a first aspect of the fifth possible realizing method in said according to said first digital signal generating a random number then it also comprises:
[0022] which has been stored in the random number is updated to the generated random number.
[0023] a second aspect this invention claims a generating a random number the device said device comprises:
[0024] conversion module is used for collecting external environment in the audio the gathered sound is converted into first digital signal;
[0025] generating module is used for according to said first digital signal generating a random number.
[0026] is combined with a second aspect in a second aspect a first possible realizing method in the conversion module comprises:
[0027] sampling unit according to the sampling frequency and sampling time length of the collected sound sampling to obtain the sampling signal;
[0028] quantization unit is used for according to sampling digit to the said sampling signal to perform quantization to obtain quantized signal;
[0029] coding unit is used for the quantized signal coding to get the first digital signal.
[0030] is combined with a second aspect in a second aspect a first possible to realize the mode of said generating module comprises:
[0031] serial connection unit is used to make said first digital signal and the stored random number to be connected in series so as to obtain the second digital signal;
[0032] determining unit is used to make said second digital signal carrying out hash calculation and the hash operation result is determined to be random number.
[0033] is combined with a second aspect a first possible realizing method in a second aspect of the first and the function of realizing method in the converting module further comprises:
[0034] setting unit used for setting the sampling frequency sampling digit and sampling time.
[0035] is combined with a second aspect and the second side of the first and the function of realizing method to the second side of the third can realizing mode in any possible realizing method in a second aspect of the fourth possible realizing method of said generating module it also comprises:
[0036] storage unit used for receiving user input end of the random number and storing the received random number.
[0037] is combined with a second aspect and the second side of the first and the function of realizing method to the second side of the fourth possible realizing method in any possible realizing method in a second aspect of the five capable of realizing mode of said device further comprises:
[0038] updating module is used for the stored random data is updated to the generated random number.
[0039] in a third aspect the invention claims a generating a random number the device said device comprises memory and processor for executing said the utility model claims a generating a random number the method of.
[0040] the embodiment of this invention does not need to provide extra hardware circuit as the random number generation source and the external environment sound as the random number generation source so that it can reduce the generating a random number the cost of; And the external environment sound it is difficult to forecast according to external environment sound generating a random number which can improve the generated random number of randomness of.
Specification attached drawing
[0041] in order to clearly the invention embodiment of this invention the technique scheme of the lower part of the embodiment describes the need to use of the attached drawing is simple to operate the introduction is showed easily the ground surface describing in the attached drawing is only the invention some embodiments of the field of common technology personnel from speaking it is not pay is creatively working under the premise of it also can be adjusted according to the attached drawing obtaining the other of the attached drawing.
[0042] picture 1 is the embodiment of this invention claims a method for generating a random number the method of flow chart;
[0043] picture 2 is the embodiment of this invention claims the other end of the random number generating method of flow chart;
[0044] picture 3 is the embodiment of this invention claims a method for generating a random number the structure of the device of picture;
[0045] picture 4 is the embodiment of this invention claims the other end of the invention claims a method of generating a random number the structure of the device of picture.
Specific implementing manner
[0046] in order to make the purpose of this invention the technology plan of the advantages and it is more clearly under the combining the attached drawing of this invention is further detail description.
[0047] the embodiment of this invention claims a generating a random number the method of the picture 1 the method comprises:
0048 step 101 ] [: Collecting external environment in the audio the gathered sound is converted into first digital signal;
0049 step 102 ] [: According to said first digital signal generating a random number.
[0050] wherein said the gathered sound is converted into first digital signal comprises:
[0051] according to the sampling frequency and sampling time length of the collected sound sampling to obtain the sampling signal;
[0052] according to sampling digit to the said sampling signal to perform quantization to obtain quantized signal;
[0053] to the quantized signal coding to get the first digital signal.
[0054] wherein said according to said first digital signal generating a random number comprises:
[0055] the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal;
[0056] the second digital signal carrying out hash calculation and the hash operation result is determined to be random number.
[0057] is further according to the sampling frequency and sampling time length of the collected sound to sample before it also comprises:
[0058] is set with sampling frequency sampling digit and sampling time.
[0059] further said the first digital signal and the stored random number to be connected in series before it also comprises:
[0060] is used for receiving user input end of the random number and storing the received random number.
[0061] further said according to said first digital signal generating a random number then it also comprises:
[0062] which has been stored in the random number is updated to the generated random number.
[0063] the embodiment of this invention does not need to provide extra hardware circuit as the random number generation source and the external environment sound as the random number generation source so that it can reduce the generating a random number the cost of; And the external environment sound it is difficult to forecast according to external environment sound generating a random number which can improve the generated random number of randomness of.
[0064] the embodiment of this invention claims a generating a random number the method of the picture 2 the method comprises:
0065 step 201 ] [: Is set with sampling frequency sampling digit and sampling time;
[0066] in the embodiment of this invention can be used through terminal sound card of collection terminal the external environment in the sound so as to present main flow of sound card of the sampling frequency is generally divided into 22.05 khz 44.1 khz and 48khz three grade; Sampling digit is 16 bits.
[0067] the sampling time is long obtaining the external environment in the voice data can be more calculating to obtain the random number random performance is higher.
0068 step 202 ] [: Is used for receiving user input end of the random number and storing the received random number;
[0069] the user inputs a random number and the input of the random number is submitted to the terminal. Terminal receiving user input of the random number and the received random number stored in buffer area.
[0070] the buffer area the length of the hash value calculating the hash value is equal to length of.
0071 [ 203 ] step: Collecting external environment in the sound according to the set sampling frequency and sampling time length of the collected sound sampling to obtain the sampling signal;
[0072] which can be through the terminal sound card of the external of collecting sound device collects the external environment in the sound.
[0073] it can collect external environment in the sound to obtain the external environment in the sound of the analog signal according to the set sampling frequency and sampling time length of the external environment in the sound of the analog signal sampled to obtain the sampling signal.
[0074] selectively the collected sound to sample before to judge whether there is need to adjust sampling time length if it is necessary to adjust sampling time according to the adjusting factor of the sampling time is adjusted or else executing step 204.
[0075] wherein each sampling is done to adjust sampling time is long it can strengthen the collected external environment in the sound of the random and it can strengthen the generated random number of randomness of.
[0076] step 204: According to sampling digit the sampling signal to perform quantization to obtain quantized signal;
[0077] wherein according to sampling digit the sample signal quality into a plurality of discrete value of the discrete value to form the quantized signal.
0078 [ 205 ] step: To the quantized signal coding to get the first digital signal;
0079 ] and [ the quantized signal to obtained by encoding the first digital signal into a binary numerical value.
[0080] wherein when the set sampling frequency sampling digit and sampling time after it is also equipped with sound card of sound channel a common channel data comprising a single channel stereo and stereo 4 sound channel and surrounding 5.1 channel. Is set with the sound card of sound channel data according to the sampling frequency sampling digit sampling time and sound channel data according to following formula calculating storing the first digital signal occupied by the bit number.
0081 ] [
[0082] wherein the said formula b is stored in the first digital signal occupied by the bit value f is the sampling frequency w is sampling digit number t s is sound channel is sampling time.
0083 step 206 ] [: The first digital signal and the stored random number to be connected in series so as to obtain the second digital signal;
[0084] the stored random number of the utility model claims a binary numerical value the embodiment of this invention is in the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal can be:
[0085] the first digital signal comprises the last level bit and the stored random number it comprises the first level bit edge is connected with the second digital signal; Or the stored random number it comprises the last level bit and the first digital signal comprises the first level bit edge is connected with the second digital signal.
[0086] the second digital signal into a binary numerical value.
[0087] wherein the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal so it can be used as the outer environment there is no noise when changing the first digital signal and the second digital signal may also be included in the stored random number by the embodiment of this invention claims the method also can be adjusted according to the second digital signal generating a random number. And the embodiment of this invention is in the first digital signal and the stored random number to be connected in series it can increase the generation of random number of randomness of.
[0088] such as the first digital signal is 01001110100 stored random number is 01001 the first digital signal comprises the last level bit o and stored random number it comprises the first level bit o and are connected with the second digital signal is 0100111010001001; Or the stored random number it comprises the last level bit i and the first digital signal comprises the first level bit o and are connected with the second digital signal is 0100101001110100.
[0089] step 207: The second digital signal carrying out hash calculation and the hash operation result is determined to be random number.
[0090] in particular to a second digital signal carrying out hash calculation to obtain the hash computing result of the first and second the digital signal of the hash value to obtain a hash value is confirmed as random number.
[0091] further which has been stored in the random number is updated to the generated random number; In order to ensure that the each sampling time is long it can generate random number to the present sampling time is long most close to the upper and a sampling time length of the generated random number and present sampling time length in the second digital signal to be connected in series to produce a new of the random number.
[0092] is wherein the stored random data is updated to the generated random number then judging whether it needs to generate random number if it needs to generate random number then returning to step 203 operation is ended.
[0093] in the embodiment of this invention not only can be controlled by sound card drive procedure of the external environment in the sound generated random number and it also can be controlled by windows system the directsound development the invention claims a directsoundcapture component from the sound card collects outside environment in the sound generated random number.
[0094] the embodiment of this invention does not need to provide extra hardware circuit as the random number generation source and the external environment sound as the random number generation source so that it can reduce the generating a random number the cost of; And the external environment sound it is difficult to forecast according to external environment sound generating a random number which can improve the generated random number of randomness of.
[0095] 3 reference picture the embodiment of this invention claims a method for generating random numbers a device for the device comprises:
[0096] 301 conversion module is used for collecting external environment in the audio the gathered sound is converted into first digital signal;
0097 [ 302 ] generating module for according to the first digital signal generating a random number.
[0098] the switching module comprises 301:
[0099] sampling unit according to the sampling frequency and sampling time length of the collected sound sampling to obtain the sampling signal;
[0100] selectively the collected sound to sample before to judge whether there is need to adjust sampling time length if it is necessary to adjust sampling time according to the adjusting factor of the sampling time to adjust the executing unit of.
- 0101 ] wherein each sampling is done to adjust sampling time is long it can strengthen the collected external environment in the sound of the random and it can strengthen the generated random number of randomness of.
[0102] quantization unit is used for according to sampling digit to sampling signal to perform quantization to obtain quantized signal;
[0103] wherein according to sampling digit the sample signal quality into a plurality of discrete value of the discrete value to form the quantized signal.
V- 0104 ] [ coding unit is used for the quantized signal coding to get the first digital signal.
0105 ] and [ the quantized signal to obtained by encoding the first digital signal into a binary numerical value.
[0106] wherein when the set sampling frequency sampling digit and sampling time after it is also equipped with sound card of sound channel a common channel data comprising a single channel stereo and stereo 4 sound channel and surrounding 5.1 channel. Is set with the sound card of sound channel data according to the sampling frequency sampling digit sampling time and sound channel data according to following formula calculating storing the first digital signal occupied by the bit number.
[0107] b = f w s t * * *
[0108] wherein the said formula b is stored in the first digital signal occupied by the bit value f is the sampling frequency w is sampling digit number t s is sound channel is sampling time.
[0109] the generating module comprises 302:
[0110] in series connection unit is used for the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal;
[0111] the stored random number of the utility model claims a binary numerical value the embodiment of this invention is in the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal can be:
[0112] the first digital signal comprises the last one bit and the stored random number it comprises the first bit split joint so as to obtain the second digital signal; Or the stored random number it comprises the last bit and the first digital signal comprises the first bit split joint so as to obtain the second digital signal.
[0113] the second digital signal into a binary numerical value.
[0114] wherein the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal so it can be used as the outer environment there is no noise when changing the first digital signal and the second digital signal may also be included in the stored random number by the embodiment of this invention claims the method also can be adjusted according to the second digital signal generating a random number. And the embodiment of this invention is in the first digital signal and the stored random number to be connected in series it can increase the generation of random number of randomness of.
[0115] determining unit is used to make said second digital signal carrying out hash calculation and the hash operation result is determined to be random number.
[0116] specifically determining unit which is used for: The second digital signal carrying out hash calculation to obtain the hash computing result of the first and second the digital signal of the hash value to obtain a hash value is confirmed as random number.
[0117] further converting module further comprises 301:
[0118] setting unit used for setting the sampling frequency sampling digit and sampling time.
[0119] further generating module it also comprises 302:
[0120] storage unit used for receiving user input end of the random number and storing the received random number.
[0121] further the device also comprises:
[0122] updating module is used for the stored random data is updated to the generated random number.
[0123] in order to ensure that the each sampling time is long it can generate random number to the present sampling time is long most close to the upper and a sampling time length of the generated random number and present sampling time length in the second digital signal to be connected in series to produce a new of the random number so as to generate the random number of randomness of more.
[0124] the embodiment of this invention does not need to provide extra hardware circuit as the random number generation source and the external environment sound as the random number generation source so that it can reduce the generating a random number the cost of; And the external environment sound it is difficult to forecast according to external environment sound generating a random number which can improve the generated random number of randomness of.
[0125] the embodiment of this invention claims a generating a random number the device of the reference picture 4 the device comprises:
[0126] 401 memory and processor for executing 402 as follows generating a random number the method of:
[0127] collecting external environment in the audio the gathered sound is converted into first digital signal;
[0128] according to said first digital signal generating a random number.
[0129] wherein said the gathered sound is converted into first digital signal comprises:
[0130] according to the sampling frequency and sampling time length of the collected sound sampling to obtain the sampling signal;
[0131] selectively the collected sound to sample before to judge whether there is need to adjust sampling time length if it is necessary to adjust sampling time according to the adjusting factor of the sampling time to adjust the executing unit of.
[0132] wherein each sampling is done to adjust sampling time is long it can strengthen the collected external environment in the sound of the random and it can strengthen the generated random number of randomness of.
[0133] according to sampling digit to the said sampling signal to perform quantization to obtain quantized signal;
[0134] wherein according to sampling digit the sample signal quality into a plurality of discrete value of the discrete value to form the quantized signal.
[0135] to the quantized signal coding to get the first digital signal.
0136 ] and [ the quantized signal to obtained by encoding the first digital signal into a binary numerical value.
[0137] wherein when the set sampling frequency sampling digit and sampling time after it is also equipped with sound card of sound channel a common channel data comprising a single channel stereo and stereo 4 sound channel and surrounding 5.1 channel. Is set with the sound card of sound channel data according to the sampling frequency sampling digit sampling time and sound channel data according to following formula calculating storing the first digital signal occupied by the bit number.
[0138] b = f w s t * * *
[0139] wherein the said formula b is stored in the first digital signal occupied by the bit value f is the sampling frequency w is sampling digit number t s is sound channel is sampling time.
[0140] wherein said according to said first digital signal generating a random number comprises:
[0141] the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal;
[0142] the stored random number of the utility model claims a binary numerical value the embodiment of this invention is in the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal can be:
[0143] the first digital signal comprises the last one bit and the stored random number it comprises the first bit split joint so as to obtain the second digital signal; Or the stored random number it comprises the last bit and the first digital signal comprises the first bit split joint so as to obtain the second digital signal.
[0144] the second digital signal into a binary numerical value.
[0145] wherein the first digital signal and the stored random number to be connected in series so as to obtain the second digital signal so it can be used as the outer environment there is no noise when changing the first digital signal and the second digital signal may also be included in the stored random number by the embodiment of this invention claims the method also can be adjusted according to the second digital signal generating a random number. And the embodiment of this invention is in the first digital signal and the stored random number to be connected in series it can increase the generation of random number of randomness of.
[0146] the second digital signal carrying out hash calculation and the hash operation result is determined to be random number.
[0147] specifically according to said second digital signal generating a random number it can be: The second digital signal carrying out hash calculation to obtain the hash computing result of the first and second the digital signal of the hash value to obtain a hash value is confirmed as random number.
[0148] is further according to the sampling frequency and sampling time length of the collected sound to sample before it also comprises:
[0149] is set with sampling frequency sampling digit and sampling time.
[0150] further said the first digital signal and the stored random number to be connected in series before it also comprises:
[0151] is used for receiving user input end of the random number and storing the received random number.
[0152] further said according to said first digital signal generating a random number then it also comprises:
[0153] which has been stored in the random number is updated to the generated random number.
[0154] in order to ensure that the each sampling time is long it can generate random number to the present sampling time is long most close to the upper and a sampling time length of the generated random number and present sampling time length in the second digital signal to be connected in series to produce a new of the random number so as to generate the random number of randomness of more.
[0155] the embodiment of this invention does not need to provide extra hardware circuit as the random number generation source and the external environment sound as the random number generation source so that it can reduce the generating a random number the cost of; And the external environment sound it is difficult to forecast according to external environment sound generating a random number which can improve the generated random number of randomness of.
[0156] need the invention is: Said claimed by the practical example of the generating a random number of the device is set on the generating a random number when the said each of the function module dividing to the example of invention in practical application can be adjusted according to need to the power energy distribution of different function module to finish the inside of the structure is divided into different function modules to finish the above described by part or all function. The other embodiment provides the generation of random number and device for generating a random number an embodiment of method for belonging to the same and the conception of the specific realizing the process method are showed in an embodiment of this is not the tag.
[0157] the field of common technology people can understand realizing the embodiment of all or part of the step can be realized by hardware can be finished by program to the instruction related to the hardware finishes the process can be stored in a computer readable storage medium in the invention claims the storage medium can be read only memory for magnetic disc or optical disc and so on.
[0158] the just of the invention better embodiment is not used for limiting the invention claims a fan the invention claims a raw spirit and it is the any modification to replace the same and so on are improved it comprises the invention claims a protection range.
Every citation, both ways
| Document | Relation | Office | Cited during |
|---|---|---|---|
| CN103617020A | Cited by | China | Search report |
| CN108009918A | Cited by | China | Search report |
| CN105426158A | Cited by | China | Search report |
| WO2016161713A1 | Cited by | World Intellectual Property Organization (WIPO) | International search |
| CN106980488A | Cited by | China | Search report |
| CN107392770A | Cited by | China | Search report |
| CN106161129A | Cited by | China | Search report |
| CN102541509A | Cites | China | Search report |
| CN102541509A | Cites | China | Search report |
| US2004162864A1 | Cites | United States of America | Search report |
| US2011268270A1 | Cites | United States of America | Search report |
| WO2012106819A1 | Cites | World Intellectual Property Organization (WIPO) | Search report |
| US5778069A | Cites | United States of America | Search report |
| US6298360B1 | Cites | United States of America | Search report |
2 priority claims, no other members on record
Priority claims2
| Document | Office | Kind | Date |
|---|---|---|---|
| 201310209936 | China | A | |
| CN20131209936 | – | – | – |
Numbers
- Publication
- 103294447
- Publication, DOCDB
- 103294447
- Publication, EPODOC
- CN103294447
- Application
- 102099360
- Application, DOCDB
- 201310209936
- Application, EPODOC
- CN20131209936
Titles3
- English
- Generating a random number method and device for
- Chinese
- 一种生成随机数的方法和装置
- English
- Method and device for generating random numbers
Classification
- IPC, 1
- G06F7 58