diff --git a/src/onionrcrypto/cryptoutils/randomshuffle.py b/src/onionrcrypto/cryptoutils/randomshuffle.py index 05f859fc..64dbf086 100644 --- a/src/onionrcrypto/cryptoutils/randomshuffle.py +++ b/src/onionrcrypto/cryptoutils/randomshuffle.py @@ -1,13 +1,6 @@ -import secrets +from random import SystemRandom + def random_shuffle(theList): myList = list(theList) - shuffledList = [] - myListLength = len(myList) + 1 - while myListLength > 0: - removed = secrets.randbelow(myListLength) - try: - shuffledList.append(myList.pop(removed)) - except IndexError: - pass - myListLength = len(myList) - return shuffledList \ No newline at end of file + SystemRandom().shuffle(myList) + return myList \ No newline at end of file