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:
The Modulo Operator in Java
Create Java Applet to Simulate Any Sorting Technique
Custom Error Pages with Spring MVC
Spring Boot - File Handling
Removing all Nulls from a List in Java
HttpClient 4 Cookbook
Remove HTML tags from a file to extract only the TEXT
Configure a Spring Boot Web Application
Java Program to Check Whether a Weak Link i.e. Articulation Vertex Exists in a Graph
Map Serialization and Deserialization with Jackson
Java Program to Implement Park-Miller Random Number Generation Algorithm
Java Program to Solve a Matching Problem for a Given Specific Case
Jackson Ignore Properties on Marshalling
Jackson – JsonMappingException (No serializer found for class)
Java Collections Interview Questions
Java Program to Check Whether Graph is DAG
Java Program to Check if a Given Set of Three Points Lie on a Single Line or Not
Spring Cloud Connectors and Heroku
A Guide to Java HashMap
Finding the Differences Between Two Lists in Java
Tạo ứng dụng Java RESTful Client với thư viện OkHttp
Dockerizing a Spring Boot Application
Java Timer
Examine the internal DNS cache
Getting Started with Custom Deserialization in Jackson
Hướng dẫn Java Design Pattern – Transfer Object
Comparing Two HashMaps in Java
HashMap trong Java hoạt động như thế nào?
Java Program to Find Nearest Neighbor for Static Data Set
Giới thiệu SOAP UI và thực hiện test Web Service
Java Program to Find the Shortest Path from Source Vertex to All Other Vertices in Linear Time
HttpAsyncClient Tutorial