From bcd123fc4f195f372cda4eb5475952e8cac25f5a Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 10 Oct 2018 12:02:41 +0100 Subject: [PATCH] Use a better RNG in modules/coins.py (secrets.choice/secrets/randbelow) --- modules/coins.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/coins.py b/modules/coins.py index 6a5c5af7..4a9e0cec 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -1,4 +1,4 @@ -import datetime, decimal, math, random, re, time +import datetime, decimal, math, re, secrets, time from src import utils SIDES = {"heads": 0, "tails": 1} @@ -163,7 +163,7 @@ class Module(object): event["stderr"].write("You don't have enough coins to bet") return - chosen_side = random.choice(list(SIDES.keys())) + chosen_side = secrets.choice(list(SIDES.keys())) win = side_name == chosen_side if win: @@ -285,7 +285,7 @@ class Module(object): # black, red, odds, evens, high (1-18), low (19-36) # 1dozen (1-12), 2dozen (13-24), 3dozen (25-36) # 1column (1,4..34), 2column (2,5..35), 3column (3,6..36) - choice = random.randint(0, 36) + choice = secrets.randbelow(0, 37) winnings = {} losses = {} if choice == 0: