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:
An Example of Load Balancing with Zuul and Eureka
New Features in Java 12
Guide to Dynamic Tests in Junit 5
Java Program to Implement SimpeBindings API
Multipart Upload with HttpClient 4
Một số ký tự đặc biệt trong Java
Java – Reader to InputStream
Java Program to Implement JobStateReasons API
How to Delay Code Execution in Java
Java Program to Implement Self Balancing Binary Search Tree
Extra Login Fields with Spring Security
Java Program to Generate All Possible Combinations Out of a, b, c, d, e
Java Program to Find MST (Minimum Spanning Tree) using Prim’s Algorithm
Java Program to Find the GCD and LCM of two Numbers
Các kiểu dữ liệu trong java
Java Program to Check whether Graph is a Bipartite using 2 Color Algorithm
Java Program to Perform the Unique Factorization of a Given Number
Guide to java.util.concurrent.BlockingQueue
Simple Single Sign-On with Spring Security OAuth2
Java Program to Create a Random Linear Extension for a DAG
How to Manually Authenticate User with Spring Security
Extract links from an HTML page
Overview of the java.util.concurrent
Sử dụng JDBC API thực thi câu lệnh truy vấn dữ liệu
OAuth2 for a Spring REST API – Handle the Refresh Token in Angular
Spring Boot - Hystrix
A Guide To UDP In Java
Java Program to Implement Flood Fill Algorithm
Handling URL Encoded Form Data in Spring REST
Java Program to Implement Shunting Yard Algorithm
Server-Sent Events in Spring
Java Program to Check the Connectivity of Graph Using BFS