diff --git a/beat/web/ui/registration/models.py b/beat/web/ui/registration/models.py
index 0a60959c1e6ce6ee6520412a2a02f7e68e178ba3..cf883cd9bd52f3bc94c802523eed15034572b61a 100644
--- a/beat/web/ui/registration/models.py
+++ b/beat/web/ui/registration/models.py
@@ -258,8 +258,8 @@ class RegistrationManager(models.Manager):
         username and a random salt.
 
         """
-        salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
-        activation_key = hashlib.sha1(salt+user.username).hexdigest()
+        salt = hashlib.sha1(str(random.random()).encode()).hexdigest()[:5]
+        activation_key = hashlib.sha1((salt+user.username).encode()).hexdigest()
         return self.create(user=user,
                            activation_key=activation_key)