import hashlib


def get_document_uid(title, body):
  """Generates a nearly unique ID for a document.

  Uses the SHA1 hash. Deterministically produces the same result for a given
  input, and almost never collides.

  Args:
    title (bytes): document title
    body (bytes): document body text

  Returns:
    uid (int)
  """
  b = '{} <sep> {}'.format(title.decode('utf-8'), body.decode('utf-8'))
  return int(hashlib.sha1(b.encode('utf-8')).hexdigest(), 16)