def digest_fileobject(file_object, algorithm=DEFAULT_HASH_ALGORITHM,<EOL>hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
<EOL>securesystemslib.formats.NAME_SCHEMA.check_match(algorithm)<EOL>securesystemslib.formats.NAME_SCHEMA.check_match(hash_library)<EOL>digest_object = digest(algorithm, hash_library)<EOL>file_object.seek(<NUM_LIT:0>)<EOL>while True:<EOL><INDENT>data = file_object.read(DEFAULT_CHUNK_SIZE)<EOL>if not data:<EOL><INDENT>break<EOL><DEDENT>if normalize_line_endings:<EOL><INDENT>while data[-<NUM_LIT:1>:] == b'<STR_LIT:\r>':<EOL><INDENT>c = file_object.read(<NUM_LIT:1>)<EOL>if not c:<EOL><INDENT>break<EOL><DEDENT>data += c<EOL><DEDENT>data = (<EOL>data<EOL>.replace(b'<STR_LIT:\r\n>', b'<STR_LIT:\n>')<EOL>.replace(b'<STR_LIT:\r>', b'<STR_LIT:\n>')<EOL>)<EOL><DEDENT>if not isinstance(data, six.binary_type):<EOL><INDENT>digest_object.update(data.encode('<STR_LIT:utf-8>'))<EOL><DEDENT>else:<EOL><INDENT>digest_object.update(data)<EOL><DEDENT><DEDENT>return digest_object<EOL>
<Purpose>
  Generate a digest object given a file object.  The new digest object
  is updated with the contents of 'file_object' prior to returning the
  object to the caller.

<Arguments>
  file_object:
    File object whose contents will be used as the data
    to update the hash of a digest object to be returned.

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

  hash_library:
    The library providing the hash algorithms (e.g., 'hashlib').

  normalize_line_endings: (default False)
    Whether or not to normalize line endings for cross-platform support.
    Note that this results in ambiguous hashes (e.g. 'abc\n' and 'abc\r\n'
    will produce the same hash), so be careful to only apply this to text
    files (not binary), when that equivalence is desirable and cannot result
    in easily-maliciously-corrupted files producing the same hash as a valid
    file.

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

  securesystemslib.exceptions.UnsupportedAlgorithmError, if an unsupported
  hashing algorithm was specified via 'algorithm'.

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

<Side Effects>
  None.

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