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:
Sử dụng CountDownLatch trong Java
Composition, Aggregation, and Association in Java
Recommended Package Structure of a Spring Boot Project
Introduction to Spring Cloud Rest Client with Netflix Ribbon
Exploring the Spring Boot TestRestTemplate
A Guide To UDP In Java
Java Program to Implement Flood Fill Algorithm
Java Program to Find the Shortest Path Between Two Vertices Using Dijkstra’s Algorithm
Java Program to Implement TreeMap API
Spring Security Login Page with React
Java Program to Solve any Linear Equation in One Variable
Java Program to Implement Ford–Fulkerson Algorithm
Java Program to Implement Quick Sort with Given Complexity Constraint
Java InputStream to Byte Array and ByteBuffer
Spring @RequestParam Annotation
Java Program to Implement Affine Cipher
Spring Cloud – Bootstrapping
Guide to the Volatile Keyword in Java
Java Program to Apply DFS to Perform the Topological Sorting of a Directed Acyclic Graph
Hướng dẫn Java Design Pattern – Visitor
Disable DNS caching
Tổng quan về ngôn ngữ lập trình java
Guide to System.gc()
Java Program to Implement the String Search Algorithm for Short Text Sizes
Java Program to Implement Bucket Sort
Converting Between an Array and a Set in Java
Check If a String Is Numeric in Java
Hướng dẫn sử dụng luồng vào ra nhị phân trong Java
Một số nguyên tắc, định luật trong lập trình
Base64 encoding và decoding trong Java 8
Java 9 Stream API Improvements
Comparing Dates in Java