I need to write a random number generator that uses an algorithm that is FIPS 140-2 compliant/certified. I am having a tough time finding anything that will work for me. Anyone done this before? I don't want to pay an arm and a leg to do this.
Using Java 8. Development environment is Mac OSX and servers are CentOs 7.
UPDATE:
Code looks like this to date.
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
public class LongRandom {
public LongRandom(){}
private Long minLong = new Long("1000000000000000000");
public List<Long> getRandomLongList(int numberOfRandom){
final SecureRandom random = new SecureRandom();
LongStream longs = random.longs(numberOfRandom, minLong, Long.MAX_VALUE).distinct();
long[] arrayLong = longs.toArray();
List<Long> list = Arrays.stream(arrayLong).boxed().collect(Collectors.toList());
return list;
}
public Long getRandomLongWinner(List<Long> potentialWinners){
final SecureRandom random = new SecureRandom();
Collections.shuffle(potentialWinners,random);
IntStream ints = random.ints(1,0,(potentialWinners.size() - 1));
return potentialWinners.get(ints.findFirst().getAsInt());
}
}