import uuid
import hashlib


def short_hash():
    """
    Generate a unique short hash (40 bytes) which is suitable as a token, secret or id
    """
    return hashlib.sha1(uuid.uuid1().bytes).hexdigest()


def long_hash():
    """
    Generate a unique long hash (128 bytes) which is suitable as a token, secret or id
    """
    return hashlib.sha512(uuid.uuid1().bytes).hexdigest()

import uuid
import hashlib


def short_hash():
    """
    Generate a unique short hash (40 bytes) which is suitable as a token, secret or id
    """
    return hashlib.sha1(uuid.uuid1().get_bytes()).hexdigest()


def long_hash():
    """
    Generate a unique long hash (128 bytes) which is suitable as a token, secret or id
    """
    return hashlib.sha512(uuid.uuid1().get_bytes()).hexdigest()

--- 
+++ 
@@ -6,11 +6,11 @@
     """
     Generate a unique short hash (40 bytes) which is suitable as a token, secret or id
     """
-    return hashlib.sha1(uuid.uuid1().get_bytes()).hexdigest()
+    return hashlib.sha1(uuid.uuid1().bytes).hexdigest()
 
 
 def long_hash():
     """
     Generate a unique long hash (128 bytes) which is suitable as a token, secret or id
     """
-    return hashlib.sha512(uuid.uuid1().get_bytes()).hexdigest()
+    return hashlib.sha512(uuid.uuid1().bytes).hexdigest()
Use bytes property with UUID objects
