This is a java program generate pseudo-random numbers using Naor-Reingold Pseudo-Random function. Let p and l be prime numbers with l |p-1. Select an element g in Fp of multiplicative order l. Then for each n-dimensional vector a = (a1, …, an). Fa(x) = g^(a1^x1 * a2^x2 …).
Here is the source code of the Java Program to Implement Naor-Reingold Pseudo Random Function. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is a java program to generate a random numbers using Naor-Reingold Psedurandom Function import java.util.Random; public class Naor_Reingold { public static void main(String args[]) { int p=7, l=3, g=2, n=4, x; int []a = {1,2,2,1}; int []bin = new int[4]; Random random = new Random(); System.out.println("The Random numbers are: "); for(int i=0; i<10; i++) { x = random.nextInt(17); for(int j=3; j>=0; j--) { bin[j] = x%2; x/=2; } int mul = 1; for(int k=0; k<4; k++) mul *= Math.pow(a[k], bin[k]); System.out.println(Math.pow(g, mul)); } } }
Output:
$ javac Naor_Reingold.java $ java Naor_Reingold The Random numbers are: 2.0 4.0 2.0 2.0 2.0 16.0 4.0 16.0 16.0 4.0
Related posts:
Java Program to Implement IdentityHashMap API
New Features in Java 8
Java Program to Generate N Number of Passwords of Length M Each
Spring Boot Integration Testing with Embedded MongoDB
Hướng dẫn Java Design Pattern – Chain of Responsibility
Java Program to Find Second Smallest of n Elements with Given Complexity Constraint
Truyền giá trị và tham chiếu trong java
Java Program to Emulate N Dice Roller
Guide to the Volatile Keyword in Java
XML-Based Injection in Spring
Mệnh đề if-else trong java
Java Program to Convert a Decimal Number to Binary Number using Stacks
Java Program to Implement SynchronosQueue API
How to Round a Number to N Decimal Places in Java
Check If a String Is Numeric in Java
Simple Single Sign-On with Spring Security OAuth2
Java Program to Generate Randomized Sequence of Given Range of Numbers
Java Program to Generate Random Numbers Using Multiply with Carry Method
Using JWT with Spring Security OAuth (legacy stack)
Java Program to Implement Sorted List
Cài đặt và sử dụng Swagger UI
Java Program to Implement Hamiltonian Cycle Algorithm
Guide to Java Instrumentation
Java Program to Implement Meldable Heap
Java Program to Represent Linear Equations in Matrix Form
Java – Convert File to InputStream
Java Program to do a Depth First Search/Traversal on a graph non-recursively
Java Program to Perform Arithmetic Operations on Numbers of Size
Converting String to Stream of chars
Java Program to Implement Bubble Sort
Request Method Not Supported (405) in Spring
Hướng dẫn Java Design Pattern – Observer