Now using SecureRandom.

This commit is contained in:
Erik C. Thauvin 2018-07-13 00:26:28 -07:00
parent ec753fdbd6
commit 7db6d76eea
3 changed files with 29 additions and 27 deletions

View file

@ -34,7 +34,7 @@ package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import java.util.Random;
import java.security.SecureRandom;
/**
* The Dice module.
@ -66,7 +66,7 @@ final public class Dice extends AbstractModule {
*/
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
final Random r = new Random();
final SecureRandom r = new SecureRandom();
int i = r.nextInt(6) + 1;
int y = r.nextInt(6) + 1;

View file

@ -39,6 +39,7 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
/**
* The Joke module.
@ -90,7 +91,8 @@ final public class Joke extends AbstractModule {
final URLConnection conn = url.openConnection();
final StringBuilder sb = new StringBuilder();
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
try (final BufferedReader reader =
new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);

View file

@ -33,9 +33,9 @@ package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* The Ping module.
@ -78,7 +78,7 @@ public class Ping extends AbstractModule {
*/
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
final Random r = new Random();
final SecureRandom r = new SecureRandom();
bot.action(PINGS.get(r.nextInt(PINGS.size())));
}