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 Repeated Squaring Algorithm
Basic Authentication with the RestTemplate
Java Timer
Luồng Daemon (Daemon Thread) trong Java
Hướng dẫn tạo và sử dụng ThreadPool trong Java
Convert Hex to ASCII in Java
Check If a File or Directory Exists in Java
Guava CharMatcher
Java Program to Implement Queue
OAuth 2.0 Resource Server With Spring Security 5
How to Remove the Last Character of a String?
New Features in Java 14
Comparing Dates in Java
Introduction to Using FreeMarker in Spring MVC
Hướng dẫn Java Design Pattern – Bridge
The Dining Philosophers Problem in Java
Java Program to Implement HashTable API
Java Program to Solve the Fractional Knapsack Problem
Java Program to Perform integer Partition for a Specific Case
Inject Parameters into JUnit Jupiter Unit Tests
Java Program to Implement RenderingHints API
Java Program to Implement Heap Sort Using Library Functions
Tìm hiểu về Web Service
Quick Guide to the Java StringTokenizer
Spring Boot Integration Testing with Embedded MongoDB
Reading an HTTP Response Body as a String in Java
Connect through a Proxy
HttpClient Connection Management
Practical Java Examples of the Big O Notation
Java Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers
Java Program to Find kth Largest Element in a Sequence
Java Program to Implement the Program Used in grep/egrep/fgrep