Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Strengthen RNG
Browse files Browse the repository at this point in the history
  • Loading branch information
StrangerCoug committed Nov 3, 2023
1 parent b2211ae commit d258696
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/java/com/github/strangercoug/freecasino/FreeCasino.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,43 @@
import com.github.strangercoug.freecasino.games.model.table.Craps;
import com.github.strangercoug.freecasino.games.model.table.RedDog;
import com.github.strangercoug.freecasino.objs.Player;
import lombok.extern.java.Log;

import java.security.DrbgParameters;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.random.RandomGenerator;

import static java.security.DrbgParameters.Capability.PR_AND_RESEED;

/**
*
* @author Jeffrey Hope <strangercoug@hotmail.com>
*/
@Log
public class FreeCasino {
/**
* Backup RNG for offline use. Using the random.org API should be preferred
* to calling this RNG, especially if it is necessary to shuffle a large
* number of cards.
*/
public static final RandomGenerator rng = new SecureRandom();
public static final RandomGenerator rng;

static {
RandomGenerator rng1;
try {
rng1 = SecureRandom.getInstance("DRBG",
DrbgParameters.instantiation(256, PR_AND_RESEED, null));
} catch (NoSuchAlgorithmException e) {
log.warning("Unable to get the defined SecureRandom instance; using the default SecureRandom instance. "
+ "This instance may not have the desired bit security strength or support prediction resistance "
+ "or reseeding.");
rng1 = new SecureRandom();
}
rng = rng1;
}

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Expand Down

0 comments on commit d258696

Please sign in to comment.