import hashlib


def get_SHA1_from_data(data):
  """Compute image SHA1.

  :param data: image buffer
  :type data: buffer
  :return: image SHA1
  :rtype: str
  """
  sha1hash = None
  try:
    sha1 = hashlib.sha1()
    sha1.update(data)
    sha1hash = sha1.hexdigest().upper()
  except:
    print("Could not read data to compute SHA1.")
  return sha1hash