Dr. V.N. Sastry - IDRBT Kumar Singhal_Random... · Dr. V.N. Sastry Professor, IDRBT ... CERTIFICATE...
-
Upload
phamkhuong -
Category
Documents
-
view
228 -
download
0
Transcript of Dr. V.N. Sastry - IDRBT Kumar Singhal_Random... · Dr. V.N. Sastry Professor, IDRBT ... CERTIFICATE...
i
Random Number Generators
Summer Internship Project Report submitted to Institute for Development and
Research in Banking Technology (IDRBT)
Submitted by:
Vipin Kumar Singhal
Bachelor in Technology, 3rd
year, 10012336
Department of Mathematics, IIT Guwahati
Under the Supervision of
Dr. V.N. Sastry
Professor, IDRBT
July 2013
ii
CERTIFICATE
This is to certify that Mr. Vipin Kumar Singhal, Roll No. 10012336, B.Tech 3
rd
year, Department Of Mathematics, IIT Guwahati has success-fully completed the
Summer Project on "Radom Number Generators" at IDRBT under my guidance.
He has work for this project for two months during May 1, 2013 to June 30,
2013.
Dr. V.N.SASTRY
Professor, IDRBT
(Project Supervisor)
iii
Table of Contents
Chapter 1:Introduction ............................................................................................................ 1
Chapter 2: Analysis of Pseudo Random Number Generators ............................................ 4
2.1 Pseudo Random Number Generators ................................................................................ 4
2.2 Primality Check ............................................................................................................... 10
2.3 Randomness Test ............................................................................................................. 12
Chapter 3: Algorithm to generate various types of Random Numbers/Sequences ......... 16
3.1 Flow Diagram ................................................................................................................ 21
Chapter 4: Implementation and Conclusions ..................................................................... 23
References ............................................................................................................................... 30
1
Chapter 1
Introduction
Basically Random numbers are numbers that occur in a sequence such that two conditions are
met: (1) the values are uniformly distributed over a defined interval or set, and (2) it is
impossible to predict future values based on past or present ones.
So essentially need a good quality random number (or series)/
sequence of random numbers
Want a sequence of Random numbers to
simulate a real life event like stock
market / for designing a game with randomness
like of a pure game
Want a 4-5 digit for tracking a banking transition / Want
some random string (or number) to allocate to every
account in some databse
Want a Random Number for encryption
of secret message / Want a secret password which has less possibilty
to crack / Want a very long alphanumeric key
to provide digital certificate or some
other use
2
Nowadays, a lot of progress is happening in the area of cryptography, simulations and games.
In all the areas we need random numbers by which we can treat mathematical processes as
real life events.
Basically a random number generator (RNG) is a computational or physical device designed
to generate a sequence of numbers or symbols that appear random and lack any pattern.
Random number generators have applications in gambling, statistical sampling, computer
simulation, cryptography, completely randomized design, and other areas where producing an
unpredictable result is desirable.
Random number generators are very useful in developing Monte Carlo-method simulations,
as debugging is facilitated by the ability to run the same sequence of random numbers again
by starting from the same random seed. They are also used in cryptography – so long as the
seed is secret. Sender and receiver can generate the same set of numbers automatically to use
as keys.
The generation of pseudo-random numbers is an important and common task in computer
programming. While cryptography and certain numerical algorithms require a very high
degree of apparent randomness, many other operations only need a modest amount of
unpredictability. Weaker forms of randomness are used in hash algorithms and in creating
amortized searching and sorting algorithms.
Some applications which appear at first sight to be suitable for randomization are in fact not
quite so simple. For instance, a system that "randomly" selects music tracks for a background
music system must only appear random, and may even have ways to control the selection of
music: a true random system would have no restriction on the same item appearing two or
three times in succession.
There are two methods used to generate random numbers. One measures some physical
phenomenon that is expected to be random and then compensates for possible biases in the
measurement process. The other uses computational algorithms that can produce long
sequences of apparently random results, which are in fact completely determined by a shorter
initial value, known as a seed or key. The latter types are often called pseudorandom number
generators.
3
A "random number generator" based solely on deterministic computation cannot be regarded
as a "true" random number generator, since its output is inherently predictable. How to
distinguish a "true" random number from the output of a pseudo-random number generator is
a very difficult problem. However, carefully chosen pseudo-random number generators can
be used instead of true random numbers in many applications. Rigorous statistical analysis of
the output is often needed to have confidence in the algorithm.
So keeping all this in mind this project is focused on the study of Pseudo Random number
Generators and various tests which verify that sequence produced is random. In final, we also
design an application for generating random numbers of different types according to user’s
choices. The intended use of application is in cryptography for mobile banking transactions.
4
Chapter 2
Analysis of Pseudo Random Number Generators and Various
Randomness tests
2.1 Pseudo Random Number Generators:
A list of most widely used pseudo random numbers generators is here with their broad
knowledge.
1) Linear Congruential Generator: It is one of the oldest, best-known and widely used
pseudorandom number generator algorithms. The best part is that it is easy to understand and
implement and is very fast. The generator works on recurrence relation given below:
1 modn nX aX c m
Where X is the sequence of pseudorandom values and
, 0m m - The “modulus”
, 0a a m - The “multiplier”
,0c c m - The “increment”
0 0,0X X m - The “seed” or “start value”
If someone wants to get random values between only 0 and 1 then do one more operation
which is:
1
1
n
n
XU
m
It will give values between 0 and 1 which will be uniformly distributed. Let’s take an
example of it:
5
Example: Suppose a = 6 and m = 11. If 0 1x then we will get a sequence
1,6,3,7,9,10,5,8,4,2,1,6 and after that entire sequence repeats. All digits are included before
a value was repeated.
A linear congruence generator that produces all 1m distinct values before repeating is said
to have full period. For having full period the parameters should have below conditions to
follow:
1. c and m are relatively prime,
2. a-1 is divisible by all prime factors of m,
3. a-1 is multiple of 4 if m is a multiple of 4.
Bad choices of these parameters can lead to ineffective implementations of LCGs. Some good
set of parameters which are used by many languages and companies are in table below:
m a c
1664525 1013904223
1103515245 12345
16807 0
22695477 1
After giving one pure random seed it generates one sequence of numbers but this sequence is
not more secure. It cannot be used for cryptographic purposes because it can be back traced.
The no.’s of this sequence follow a pattern. They have a very strong correlation among them.
If we plot no.’s in doublet 1,i iU U then these lies on some lines in 2-D plane and if we plot
no.’s in triplet 1 2, ,i i iU U U then these lies on some planes. The number of planes will be
maximum
1
nm . The pictorial looks are below:
6
Figure 1: Plotting of points in 2-dimesion
Figure 2: Plotting of points in 3-dimesion
Another problem with LCGs is that if parameters are not chosen wisely then it will lead to
shorter periods, which most of the times does not satisfy our requirements.
2) Multiplicative Linear Congruential generator: This is also known as “Lehmer RNG”
and sometimes called the Park-Miller RNG. This is a special type of linear Congruential
generator where 0c . The generator works on recurrence relation:
7
1 modn nX aX m
Where X is the sequence of pseudorandom values and
, 0m m - The “modulus”
, 0a a m - The “multiplier”
0 0,0X X m - The “seed” or “start value”
If someone wants to get random values between only 0 and 1 then do one more operation
which is:
1
1
n
n
XU
m
Its maximal possible period is m-1 when m is a prime number. If c = 0 and m is prime, full
period is achieved from any 0 0X if:
(a) 1 1ma is a multiple of m.
(b) 1ja is not a multiple of m for 1: 2j m .
A number a satisfying these two properties is called a primitive root of m.
A very good use of this generator is with values 312 1m and
57 16,807a which are
followed by Carbon Library of Apple Incorporation. With these values it is also known as
MINSTD. The properties of it are also like above generator.
3) Blum Blum Shub: It was proposed in 1986 by Lenore Blum, Manuel Blum and Michael
Shub. This works on below recurrence relation:
1 modn n nX X X m
8
Where X is the sequence of pseudorandom values and
, 0m m - The “modulus”
0 0,0X X m - The “seed” or “start value”
Here m pq , where p and q are two large primes.
This generator is not very famous but it is very much secure. Hence mostly it is used in
cryptography and not in simulation purposes. Its first value is totally dependent on seed. So
the sequence will also be dependent on seed only which can be pure random every time.
4) Inverse Congruential Generator: This in a nonlinear Congruential generator. So
sequence coming from that does not lies on planes. The formula of this algorithm is:
0
1
1
1
mod f 0
f 0
n n n
n n
seedX
X aX c q i X
X c i X
Where X is the sequence of pseudorandom values and
, 0q q - The “modulus”
, 0a a m - The “multiplier”
,0c c m - The “increment”
0 0,0X X m - The “seed” or “start value”
The sequence 0n n
x
must have i jx x after finitely many steps and since the next element
depends only on its direct predecessor, so 1 1i jx x . The maximum period T for a function
modulo m will be T m . The sufficient condition for maximum sequence period is a proper
choice of parameters a and c according to the algorithm.
9
5) Lagged Fibonacci generator: This generator is based on Fibonacci sequence. This is also
an improvement in Linear Congruential Generator. This works on recurrence relation below:
1 2 modn n nS S S m
There is a more generalized version of this generator also, which is:
mod , 0n n j n kS S S m j k
Here any new term comes after operation on combination of any two previous terms. The *
operator can be any binary operation. Addition, subtraction, multiplication or XOR are the
most famous operator for working. User can also decide the values of j and k according to
his/her choice. If the operation used is addition, then the generator is described as an Additive
Lagged Fibonacci Generator or ALFG, if multiplication is used, it is a Multiplicative Lagged
Fibonacci Generator or MLFG, and if the XOR operation is used, it is called a Two-tap
generalized feedback shift register or GFSR.
Some very popular pairs for values of j and k are:
7, 10 , 5, 17 , 24, 55 , 128, 159 ,
273, 607 , 6, 31 , 31, 63 , 97, 127
j k j k j k j k
j k j k j k j k
In all these cases we have to generate first k random values with the help of some other
random number generator, which may be a LCG or any other.
Lagged Fibonacci generators have maximum period of 12 1 2k m if operation of addition
or subtraction is used. If exclusive-or (XOR) is used then the period will be 2 1k k at
maximum. If multiplication is used then the period degrades by 1/4th
of the period of additive
case.
This is a widely used generator for random number generation. (But there are some problems
with it also like if initial values are not good, they don’t follow randomness properties, then it
may happen that a pattern can be recognized in generated sequence using these values). By
the way it is a pretty good generator for cryptographic uses.
10
6) Multiply-With-Carry: This method was proposed by George Marsaglia (1991) for
generating sequences of random integers. This is a very fast method which can generate
random numbers with very large periods ranging around 602 to 200002 . It takes an initial set of
values to start. It works on the algorithm:
1
1
modn n r n
n r n
n
x ax c m
ax cc n r
m
This is a lag-r MWC generator which requires a base m, a multiplier a, and a set of 1r
random seeds 0 1 2 1, , ,......... rx x x x and an initial carry 1rc a . With these parameters a
sequence can be generated 1 2, , ,.........r r rx x x . These are not in much use.
These are basically main pseudo random number generators which are used to generate
sequence of random numbers with proper choices of parameters. The generated sequence of
random numbers has to follow some characteristics and some tests which are described
below:
2.2 Primality Check:
Prime no.’s has a lot of importance especially in the area of cryptography where encryption
algorithms are written on the base of prime number and many other uses are there. So we
always need lots of prime no.’s and if we get a number from somewhere then there is always
a need to check whether it is a prime or not. Basically a prime number (or a prime) is a
natural number greater than 1 that has no positive divisors other than 1 and itself. There are
ways to check whether a number is prime or not, some of them are below:
11
Method 1) Trial Method: It is the simplest test for checking primality of a number. Basically
it works on the definition of prime number. So basically in this method we check by dividing
a number many times. Follow the below steps in this method:
Let n is the number for testing.
Divide this number by 2. If it comes out divisible by 2 then it is not a prime number. If
it comes not divisible then go to next option.
Divide this number by 3. If it comes out divisible by 3 then it is not a prime number. If
it comes not divisible then go to next option.
Divide this number by each number between 4 to 1/2n . If there comes no number less
than 1/2n which divides n then it is a prime number. Basically the reason behind
going till 1/2n is that no number 16n x y exists such that x and y both exceeds
the square root of n.
If someone wants to more optimize this algorithm then he/she can skip the numbers which are
multiple of earlier numbers like someone can skip 4 if some number is divisible by 2.
Likewise it can be improved more.
Method 2) Fermat Primality test: This method is probabilistic test to declare whether a
number is prime or not. Basically it tests for compositeness, rather than primeness. By testing
this number we can only declare that the number is composite or not, but we can’t declare that
it is only prime. The concept behind this test is:
If a number p is prime then choose a number a, such that 1 a p and try to prove
1 1 modpa p . If it does not comes true for any number a then the number is surely
composite, but if this not happens then the number is probably prime not surely.
Method 3) Miller Rabin test: This also works like Fermat test. The algorithm on which it
works is:
Let n be an odd number for testing.
Factor all powers of 2 from 1n , expressing it in the form 1 2sn d where d is
odd.
12
Pick a random number a between 2 and 1n .
Compute modda n . If 1 or 1 modda n , then n passes the Miller-Rabin test
and is probably prime.
Otherwise, compute 12 4 8 2, , ,......and
sd d d da a a a
. If one of these equals 1 mod n ,
then n is also passes and probably prime.
If n passes the Miller-Rabin test for some value of a, try another a to improve the
confidence in the outcome of the test.
If n is in fact prime, it will pass with any value of a. If n is composite, it will fail for at
least three quarters of the values of a.
2.3 Randomness Tests:
So we have generated random sequences from pseudo random number generator. Now
question comes how can we claim whether the sequence is random or not?
Pseudo random number generators do not always generate sequences which are sufficiently
random and generate very repetitive patterns. Many generated sequences fail tests of
randomness. The use of an ill-conceived random number generator will result in invalid
experiments, due to lack of randomness. So for testing randomness there are some tests but
they are differently applicable at different places. Some of those tests are described below
with their description.
The Frequency Test, is very basic test for checking to make sure that there are
roughly same no. of 0s, 1s, 2s, 3s etc.
The Serial Test, does the same thing but the sequences of two digits at a time
(00,01,02 etc.), comparing their observed frequencies with their hypothetical
predictions are they equally distributed.
13
The Poker Test, tests for certain sequences of five numbers at a time (aaaaa, aaaab,
aaabb, etc.) based on hands in the game poker.
The Gap Test, looks at the distances between zeroes (00 would be a distance of 0,
030 would be a distance of 1, 02250 would be a distance of 3, etc.).
These tests were proposed by Kendall and Smith. If a given sequence was able to pass all
of these tests within a given degree of significance (generally 5%), then it was judged to
be, in their words "locally random". Kendall and Smith differentiated "local randomness"
from "true randomness" in that many sequences generated with truly random methods
might not display "local randomness" to a given degree — very large sequences might
contain many rows of a single digit. This might be "random" on the scale of the entire
sequence, but in a smaller block it would not be "random" (it would not pass their tests),
and would be useless for a number of statistical applications.
Apart from these George Marsaglia proposed Diehard Tests to check statistical properties
in 1995. Diehard tests contain a list of tests which are:
Birthday Spacings: Choose random points on a large interval. The spacings
between the points should be asymptotically exponentially distributed.
Overlapping permutations: Analyze sequences of five consecutive random
numbers. The 120 possible orderings should occur with statistically equal
probability.
Ranks of matrices: Select some number of bits from some number of random
numbers to form a matrix over 0,1 , and then determine the rank of the matrix.
Count the ranks.
Monkey tests: Treat sequences of some number of bits as "words". Count the
overlapping words in a stream. The number of "words" that don't appear should
follow a known distribution. The name is based on the infinite monkey theorem.
14
Count the 1s: Count the 1 bits in each of either successive or chosen bytes.
Convert the counts to "letters", and count the occurrences of five-letter "words".
Parking lot test: Randomly place unit circles in a 100 100 square. If the circle
overlaps an existing one, try again. After 12,000 tries, the number of successfully
"parked" circles should follow a certain normal distribution.
Minimum distance test: Randomly place 8,000 points in a 10,000 10,000
square, and then find the minimum distance between the pairs. The square of this
distance should be exponentially distributed with a certain mean.
Random spheres test: Randomly choose 4,000 points in a cube of edge 1,000.
Center a sphere on each point, whose radius is the minimum distance to another
point. The smallest sphere's volume should be exponentially distributed with a
certain mean.
The squeeze test: Multiply 231 by random floats on [0, 1) until we reach 1.
Repeat this 100,000 times. The number of floats needed to reach 1 should follow
a certain distribution.
Overlapping sums test: Generate a long sequence of random floats on [0, 1).
Add sequences of 100 consecutive floats. The sums should be normally
distributed with characteristic mean and sigma.
Runs test: Generate a long sequence of random floats on [0, 1). Count ascending
and descending runs. The counts should follow a certain distribution.
15
The craps test: Play 200,000 games of craps, counting the wins and the number
of throws per game. Each count should follow a certain distribution.
In this chapter we covered various pseudo random number generators which can generate a
long sequence of random numbers using some parameters. After that we covered primality
check and test for checking randomness of a sequence.
16
Chapter 3
Design of Algorithm to generate Random Numbers/Sequences
After going through literature survey now comes the implementation part which is the most
important part of project. As the aim of the project was to design an algorithm which can be
implemented on pc and mobile devices to produce any kind of random numbers with user’s
flexibility. So the designed algorithm was similar to all the generators for generating random
numbers. Since this algorithm uses minimum possible functions to generate sequence of
random numbers so it is optimized in terms of time and resources. The algorithm for Linear
Congruential generator for generating different type of random sequences is below:
1. Since the working recurrence relation is 1 modi iX aX b m , so choose the values of a,
b and m appropriately such that period should be very high.
2. Now choose which type of random string /number user wants to generate. Cases are written
below according to the type of user’s choice.
1) Numeric Random Number
Take user’s input for different things which are Length of Random Number,
Quantity of random number and if user wants to enter a seed then take entry of
seed either take the default value from clock or some other inbuilt pure random
unit in ourr device.
Run the function 1 modi iX aX b m using value of all the parameters and
value of seed. Every time a value comes.
Calculate 1
1
n
n
XU
m
. This comes a random number in decimal.
Pick first 14 digits after decimal in 1nU and present that a random number.
17
If user’s demanded length is more than 14 then concatenate the numbers and get
desired length. If user’s demanded length is less than 14 then chop off the
numbers and get desired length
2) Alphabetic Uppercase String:
Take user’s input for different things which are Length of Random Number,
Quantity of random number and if user wants to enter a seed then take entry of
seed either take the default value from clock or some other inbuilt pure random
unit in our device.
Run the function 1 modi iX aX b m using value of all the parameters and
value of seed. Every time a value comes.
Calculate 1
1
n
n
XU
m
. This comes a random number in decimal.
Pick first 14 digits after decimal in 1nU and present that a random number.
for( int 0; 7;i i i )
Number = Take two digits from left from this number.
Get Number % 26 .
Give the Uppercase alphabet corresponding to this achieved number.
Here only 7 digits will come corresponding to every 14 digit numeric number.
If user’s demanded length is more than 7 then concatenate the numbers and get
desired length. If user’s demanded length is less than 7 then chop off the numbers
and get desired length
3) Alphabetic Lowercase String:
Take user’s input for different things which are Length of Random Number,
Quantity of random number and if user wants to enter a seed then take entry of
seed either take the default value from clock or some other inbuilt pure random
unit in our device.
Run the function 1 modi iX aX b m using value of all the parameters and
value of seed. Every time a value comes.
Calculate 1
1
n
n
XU
m
. This comes a random number in decimal.
Pick first 14 digits after decimal in 1nU and present that a random number.
18
for( int 0; 7;i i i )
Number = Take two digits from left from this number.
Get Number % 26 .
Give the Lowercase alphabet corresponding to this achieved number.
Here only 7 digits will come corresponding to every 14 digit numeric number.
If user’s demanded length is more than 7 then concatenate the numbers and get
desired length. If user’s demanded length is less than 7 then chop off the numbers
and get desired length
4) Binary String:
Take user’s input for different things which are Length of Random Number,
Quantity of random number and if user wants to enter a seed then take entry of
seed either take the default value from clock or some other inbuilt pure random
unit in our device.
Run the function 1 modi iX aX b m using value of all the parameters and
value of seed. Every time a value comes.
Calculate 1
1
n
n
XU
m
. This comes a random number in decimal.
Pick first 14 digits after decimal in 1nU and present that a random number.
for( int 0; 14;i i i )
Number = Take one digits from left from this number.
Get Binary representation of that number. It will come in length of 4 digits.
If user’s demanded length is more than 7 then concatenate the numbers and get
desired length. If user’s demanded length is less than 7 then chop off the numbers
and get desired length
5) Alphanumeric String In Fixed Pattern:
Take user’s input for different things which are Length of Random Number,
Quantity of random number and if user wants to enter a seed then take entry of
seed either take the default value from clock or some other inbuilt pure random
unit in our device.
After taking that, take Pattern also from user in which pattern he/she wants his
random string.
19
Run the function 1 modi iX aX b m using value of all the parameters and
value of seed. Every time a value comes.
Calculate 1
1
n
n
XU
m
. This comes a random number in decimal.
Pick first 14 digits after decimal in 1nU and present that a random number.
for int 0; 7;i i i
Number = Take two digits from left from this number.
Check the character from left in input pattern.
if(Lowercase alphabet)
Get Number % 26 .
Give the Lowercase alphabet corresponding to this achieved number.
else if(Uppercase Alphabet)
Get Number % 26 .
Give the Uppercase alphabet corresponding to this achieved number.
else
Assuming it is a number. Take 1st digit of that 2 digit number and
show it.
Here only 7 digits will come corresponding to every 14 digit numeric number.
If user’s demanded length is more than 7 then concatenate the numbers and get
desired length. If user’s demanded length is less than 7 then chop off the numbers
and get desired length
6) Alphanumeric String In Random Pattern:
Take user’s input for different things which are Length of Random Number,
Quantity of random number and if user wants to enter a seed then take entry of
seed either take the default value from clock or some other inbuilt pure random
unit in our device.
Run the function 1 modi iX aX b m using value of all the parameters and
value of seed. Every time a value comes.
Calculate 1
1
n
n
XU
m
. This comes a random number in decimal.
20
Pick first 14 digits after decimal in 1nU and present that a random number.
for int 0; 7;i i i
Number = Take two digits from left from this number.
Check the a = Number’s 1st digit and allocate Lowercase, Uppercase or
numeric to it in a different file.
if(a corresponds to Lowercase alphabet)
Get Number % 26 .
Give the Lowercase alphabet corresponding to this achieved number.
else if(a corresponds to Uppercase Alphabet)
Get Number % 26 .
Give the Uppercase alphabet corresponding to this achieved number.
else
Assuming it is a number. Take 1st digit of that 2 digit number and
show it.
Here only 7 digits will come corresponding to every 14 digit numeric number.
Here every coming number is corresponding to produced 14 digit random number. So it is
totally unpredictable.
If user’s demanded length is more than 7 then concatenate the numbers and get
desired length. If user’s demanded length is less than 7 then chop off the numbers and
get desired length
All other generators also works like above algorithm. Only algorithm generating 14 digit
numbers changes.
The Flow diagram of the code is looks like below:
21
Every generator has given facilities to generate different Random Strings.
Choose the generator to implement to generate sequence of Random
Numbers
Mixed Congruential
Generator
Lehmer Random Number
Generator
Lagged Fibbonacci Generator
Blum Blum Shub
Generator
Or want to check whether a number is prime or not?
Numeric •Choose length of Random String •How many numbers •Want to choose their own seed or not
Alphabetic Uppercase
•Choose length of Random String •How many numbers •Want to choose their own seed or not
Alphabetic Lowercase
•Choose length of Random String •How many numbers •Want to choose their own seed or not
Binary •Choose length of Random String •How many numbers •Want to choose their own seed or not
Alphanumeric fixed pattern
•Choose length of Random String •How many numbers •Write pattern in which want to generate your string. •Want to choose their own seed or not
Alphanumeric Random
•Choose length of Random String •How many numbers •Want to choose their own seed or not
22
So this algorithm is able to generate sequence of any type random string/ numbers with any
length and any quantity. It gives all the flexibilities to user to select his/her own choices at
different steps.
23
Chapter 4
Application Development and Conclusions
The Application developed is written in core java. It works on pc and there is a mobile edition
too. The application produces random strings/numbers in minimum time using minimum
resources. This code hasn’t use any typical calculation like using BigDecimal etc. which uses
a lot of precision calculation. So it works on mobile finely. A tour of software on pc with
some inputs is there:
The first interface comes after running:
Let’s choose 2 – “Multiplicative RNG”. After choosing 2
Now it asks for our desired type of string. Let’s enter 6 for random Alphanumeric.
24
Now it asks for desired length. Let’s enter 50.
Now it asks for quantity. Let’s enter 30
Now it asks whether we want to enter a seed or not. If we want to enter a seed then enter by
following instruction otherwise it will take some default value. Let’s enter some seed 45768.
25
Just after entering the details, the no.’s comes:
The 30 generated alphanumeric numbers of 50 digit length are:
j8t28nn2O8Vmg55R8228WXol822tr0280i8gOn8On0NBqmU002
0B0h0o00SjPtumMe8558Bm8Q8jS5kTi80T52l5k05U82MTA2rf
Q5KSU20h085RrqQX0X02U252Wr02X8AuX002ivf58S22m2N5i2
kkSBlqOVko5m2L0n2TTV25eoXn80T8mj5Re0L250ST5lr80YZ2
q8O0Rn2j5ll22pv5pS2OlkOj500viTX0TMTn520Un8BmjM2588
V5QPv05kOvS805UM2rkem5u55OA0S22g0qUqWmBPsWnZA00S02
mt58g0SpUN8n0sp2p8Tjl8W2VQ5lU08jg5Wpkp0j8e8rU8n8sS
oX8Sl5Wp22t2itlls0n8Um8RT8W8Q2e0m2X0mUmp5vn0nvSV0X
lj88528gXS2lnPmS05ntPofg82P22PoQ25QiYWgKBVk2Om2kTP
Vuj55W85o8l82vV8Ojng5XnQkm20Z02B0Sm2lo50Z2uV5r20fU
52u0f0QU2KRoO522588AX222qqsmpV2TSWRqf500o85jSnjvin
S80r2n0ReW5SPP8fsO2TBVXnmr5N25U05kS50025Sf0mTRQ228
L205Y5X28US5nOL2Q02OnA0nnSRLg85A8mom22WjvON5S5m2SS
T5L0RRrXV8jpTP55N5Oj88Qenu02S02502SR88lQ2PrMj8BpW8
Tjo525V2eV05MnK2o25t0U8850BP2vULUWV2Nfh85Q85002r8n
S52vLVZj0V20rP25k52pBlOWV5820OZnlhL0f222S8qjukT502
2n580tAOr0Tl05A820eA5QTnl085550Tl228jLVX5nsV5k5TSP
OXW8qrU20rV00VjVrjr5Kep8iSv000lv5sjPLqq58XrmTWsl5i
26
mY8i8OSROh82jZ8Uv5U2U22Rr5i5gNW0nrlhmp50VNWoj5055O
RBf00KjWX0nLs2PmW8X82n055p2Rk28KrTt5MQS2OSqis5qrT0
2Pq0O8Lh0k82N8N0Th8mpkNS28m0p505gkeB20UslApk022T80
5X5h0p52SLQ85m2p0T5m2jU5085fi2r5j5Y5h22NW2RUW5V288
oqPT58Vq5qYU5ljQ2l0285lBS0250K5QQn08PU20n0Z55r8W88
5o5qn8VW8ToQnZ5iBfWW55qSnp80W8m2o0882SSOj2VQ5m0205
80Tjuh5Pn55gO5SpB8qO508N5v05S5rRnTiSW2025n20Ko8WkX
28f222R5mv8S8Qp5i2O0roMoWXKnn08Sm5VQn8NhS2mN25fWVm
sOSe25825RUmP5QTU0M8rnu2kujqqpj0sr80Si58j5U25SBuq5
kB20o0oT58r8T88g02uSS8Lmi55N82VTPu0kjS8XnsjWvh8UPB
n2TX5S5r0QZj5Th558r2W0PK2LmP2Qli00U50fs8PTTBssN08l
QjMVjOKppMRO8S5Oo2WlTO28tnqBUZ5XiXhi0o802nSKk280Wp
This was one tour. Let’s have another with Alphabetic lowercase letters. We will generate it
with mixed LCG. We will take random number length as 25, quantity as 10, seed as 384.
27
The other implementation was on mobile devices. It was implemented in J2ME. To
implement Java Code in J2ME, we will need the following:
1. The Java 2 SDK (formerly known as a JDK); J2SE 1.6 SDK is recommended.
2. NetBeans IDE 7.2.1
Java ME SDK Tools plugin
Emulator Platform : CLDC Oracle Java(Tm) Platform ME SDK 3.2
3. J2ME mobile handheld device.
Device Configuration : CLDC-1.1
Device Profile : MIDP-2.0
4. Lightweight UI Toolkit(LWUIT.jar added in resource)
Now let’s take a tour on Mobile device also:
28
Both windows shows user has full flexibility to choose his own generator and own type of
string. The other window shows the inputs to be taken from user and the last window shows
the output on screen.
29
Conclusion and Future Aspects:
In this project we analyzed various pseudo random number generators. We concluded their
pro’s and con’s. We also enlightened the tests for randomness and gone through primality
check. Finally we implemented the algorithm of Random Number Generators on mobile and
pc. This application is working on minimum resources and time.
This can be used for cryptography, simulation purposes and many other purposes. It can be
used in banking technology too in many areas like for password generation, allotting account
numbers, allotting random numbers per transaction in internet banking etc.
30
References:
[1] P. Hellekalek, “Good random number generators are (not so) easy to find”, Mathematics
and Computers in Simulation 46, 1998, pp. 485-505.
http://www.ics.uci.edu/~smyth/courses/ics178/random_number_generators_article.pdf
[2] Sakamoto M., Morito S, “Combination of multiplicative Congruential random number
generators with safe prime modulus”, Simulation Conference Proceedings, 1995. Winter, pp.
309-315.
[3] Frieze A. M., Kannan R, Lagarias J. C. “Linear Congruential Generators Do Not Produce
Random Sequences”, Foundations of Computer Science, 1984.25th
Annual Symposium, pp.
480-484
[4] Durst M. J., “Using Linear Congruential Generators for Parallel Random number
Generation”, Simulation Conference Proceedings, 1989.Winter, pp. 462-466
[5] Yasuda, S., Tanamoto, T., Ohba, Ryuji, Abe, K., Nozaki, H., Fujita, “Shinobu Physical
random number generators for cryptographic application in mobile devices”, Solid-State
Circuits Conference, 2005, pp 399-402
[6] http://en.wikipedia.org/wiki/Inversive_congruential_generator
[7] http://en.wikipedia.org/wiki/ISAAC_(cipher)
[8] http://en.wikipedia.org/wiki/Blum_Blum_Shub
[9] http://en.wikipedia.org/wiki/Sophie_Germain_prime
[10] http://en.wikipedia.org/wiki/Mersenne_twister
[11] http://en.wikipedia.org/wiki/Multiply-with-carry
[12] http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator
[13] http://en.wikipedia.org/wiki/Lagged_Fibonacci_generator
[14] http://en.wikipedia.org/wiki/Generalised_feedback_shift_register
[15] http://www.wikihow.com/Check-if-a-Number-Is-Prime
[16] http://en.wikipedia.org/wiki/Fermat_primality_test
[17] http://en.wikipedia.org/wiki/Diehard_tests
[18] http://en.wikipedia.org/wiki/Statistical_randomness
[19] Paul Glasserman, “Monte Carlo Methods in Financial Engineering”, Springer.