package de.ivu.elect.util;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;

public class ElectRandom {

  public static final AtomicBoolean USE_STRONG_RANDOM_GENERATOR = new AtomicBoolean(false);

  public static SecureRandom getRandom(){
    // ELECT-8368
    if (USE_STRONG_RANDOM_GENERATOR.get()){
      try {
        return SecureRandom.getInstanceStrong();
      } catch (NoSuchAlgorithmException e) {
        // Ignore
      }
    }
    return new SecureRandom();
  }
}
