From f23f107b331fcfe5c11dec0921dbf105e3457cf8 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 13 Oct 2018 20:11:24 +0200 Subject: [PATCH] Correct hashlib calls --- evennia/commands/default/comms.py | 2 +- evennia/prototypes/prototypes.py | 2 +- evennia/prototypes/spawner.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/evennia/commands/default/comms.py b/evennia/commands/default/comms.py index 758d1fa793..2b8a0b21e0 100644 --- a/evennia/commands/default/comms.py +++ b/evennia/commands/default/comms.py @@ -922,7 +922,7 @@ class CmdIRC2Chan(COMMAND_DEFAULT_CLASS): self.msg("Account '%s' already exists and is not a bot." % botname) return else: - password = hashlib.md5(str(time.time())).hexdigest()[:11] + password = hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:11] try: bot = create.create_account(botname, None, password, typeclass=botclass) except Exception as err: diff --git a/evennia/prototypes/prototypes.py b/evennia/prototypes/prototypes.py index 5a37f29216..642e3b9938 100644 --- a/evennia/prototypes/prototypes.py +++ b/evennia/prototypes/prototypes.py @@ -92,7 +92,7 @@ def homogenize_prototype(prototype, custom_keys=None): if "prototype_key" not in prototype: # assign a random hash as key homogenized["prototype_key"] = "prototype-{}".format( - hashlib.md5(str(time.time())).hexdigest()[:7]) + hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:7]) if "typeclass" not in prototype and "prototype_parent" not in prototype: homogenized["typeclass"] = settings.BASE_OBJECT_TYPECLASS diff --git a/evennia/prototypes/spawner.py b/evennia/prototypes/spawner.py index 5d72f9ba3b..3cf2310c13 100644 --- a/evennia/prototypes/spawner.py +++ b/evennia/prototypes/spawner.py @@ -230,14 +230,14 @@ def prototype_from_object(obj): # no unambiguous prototype found - build new prototype prot = {} prot['prototype_key'] = "From-Object-{}-{}".format( - obj.key, hashlib.md5(str(time.time())).hexdigest()[:7]) + obj.key, hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:7]) prot['prototype_desc'] = "Built from {}".format(str(obj)) prot['prototype_locks'] = "spawn:all();edit:all()" prot['prototype_tags'] = [] else: prot = prot[0] - prot['key'] = obj.db_key or hashlib.md5(str(time.time())).hexdigest()[:6] + prot['key'] = obj.db_key or hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:6] prot['typeclass'] = obj.db_typeclass_path location = obj.db_location @@ -690,7 +690,7 @@ def spawn(*prototypes, **kwargs): # we must always add a key, so if not given we use a shortened md5 hash. There is a (small) # chance this is not unique but it should usually not be a problem. val = prot.pop("key", "Spawned-{}".format( - hashlib.md5(str(time.time())).hexdigest()[:6])) + hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:6])) create_kwargs["db_key"] = init_spawn_value(val, str) val = prot.pop("location", None)