Normalize the encoding names for Latin-1 and UTF-8 to
'latin-1' and 'utf-8'.

These are optimized in the Python Unicode implementation
to result in more direct processing, bypassing the codec
registry.

Also see issue11303.
diff --git a/Lib/random.py b/Lib/random.py
index cb49d56..f29803e 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -114,7 +114,7 @@
         if version == 2:
             if isinstance(a, (str, bytes, bytearray)):
                 if isinstance(a, str):
-                    a = a.encode("utf8")
+                    a = a.encode("utf-8")
                 a += _sha512(a).digest()
                 a = int.from_bytes(a, 'big')