def is_encrypted_file(file_obj, start_pos=0, count=(-1)):
 current_position = file_obj.tell()
 try:
  file_obj.seek(start_pos)
  vaulttext = file_obj.read(count)
  try:
   b_vaulttext = to_bytes(to_text(vaulttext, encoding='ascii', errors='strict'), encoding='ascii', errors='strict')
  except (UnicodeError, TypeError):
   return False
 finally:
  file_obj.seek(current_position)
 return is_encrypted(b_vaulttext)

def is_encrypted_file ( file_obj , start_pos = 0 , count = ( - 1 ) ) : current_position = file_obj . tell ( ) try : file_obj . seek ( start_pos ) vaulttext = file_obj . read ( count ) try : b_vaulttext = to_bytes ( to_text ( vaulttext , encoding = 'ascii' , errors = 'strict' ) , encoding = 'ascii' , errors = 'strict' ) except ( UnicodeError , TypeError ) : return False finally : file_obj . seek ( current_position ) return is_encrypted ( b_vaulttext )
test if the contents of a file obj are a vault encrypted data blob .