def _remove_private_key(content):
 prefix = '-----BEGIN PRIVATE KEY-----'
 suffix = '-----END PRIVATE KEY-----'
 start = content.find(prefix)
 if (start < 0):
  return content
 trim_start = ((start + len(prefix)) + 5)
 end = content.find(suffix, trim_start)
 if (end < 0):
  end = len(content)
 trim_end = (end - 5)
 if (trim_end <= trim_start):
  return content
 return ((content[:trim_start] + '...REMOVED...') + content[trim_end:])

def _remove_private_key ( content ) : prefix = '-----BEGIN PRIVATE KEY-----' suffix = '-----END PRIVATE KEY-----' start = content . find ( prefix ) if ( start < 0 ) : return content trim_start = ( ( start + len ( prefix ) ) + 5 ) end = content . find ( suffix , trim_start ) if ( end < 0 ) : end = len ( content ) trim_end = ( end - 5 ) if ( trim_end <= trim_start ) : return content return ( ( content [ : trim_start ] + '...REMOVED...' ) + content [ trim_end : ] )
remove most of the contents of a private key file for logging .