def digest(algorithm=DEFAULT_HASH_ALGORITHM, hash_library=DEFAULT_HASH_LIBRARY):
<EOL>securesystemslib.formats.NAME_SCHEMA.check_match(algorithm)<EOL>securesystemslib.formats.NAME_SCHEMA.check_match(hash_library)<EOL>if hash_library == '<STR_LIT>' and hash_library in SUPPORTED_LIBRARIES:<EOL><INDENT>try:<EOL><INDENT>return hashlib.new(algorithm)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise securesystemslib.exceptions.UnsupportedAlgorithmError(algorithm)<EOL><DEDENT><DEDENT>elif hash_library == '<STR_LIT>' and hash_library in SUPPORTED_LIBRARIES: <EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise securesystemslib.exceptions.UnsupportedLibraryError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' + repr(SUPPORTED_LIBRARIES))<EOL><DEDENT>
<Purpose>
  Provide the caller with the ability to create digest objects without having
  to worry about crypto library availability or which library to use.  The
  caller also has the option of specifying which hash algorithm and/or
  library to use.

  # Creation of a digest object using defaults or by specifying hash
  # algorithm and library.
  digest_object = securesystemslib.hash.digest()
  digest_object = securesystemslib.hash.digest('sha384')
  digest_object = securesystemslib.hash.digest('sha256', 'hashlib')

  # The expected interface for digest objects.
  digest_object.digest_size
  digest_object.hexdigest()
  digest_object.update('data')
  digest_object.digest()

  # Added hash routines by this module.
  digest_object = securesystemslib.hash.digest_fileobject(file_object)
  digest_object = securesystemslib.hash.digest_filename(filename)

<Arguments>
  algorithm:
    The hash algorithm (e.g., 'md5', 'sha1', 'sha256').

  hash_library:
    The crypto library to use for the given hash algorithm (e.g., 'hashlib').

<Exceptions>
  securesystemslib.exceptions.FormatError, if the arguments are
  improperly formatted.

  securesystemslib.exceptions.UnsupportedAlgorithmError, if an unsupported
  hashing algorithm is specified, or digest could not be generated with given
  the algorithm.

  securesystemslib.exceptions.UnsupportedLibraryError, if an unsupported
  library was requested via 'hash_library'.

<Side Effects>
  None.

<Returns>
  Digest object (e.g., hashlib.new(algorithm)).