code: def format_private_key(key, heads=True):
          
          private_key = key.replace('\x0D', '')
          private_key = private_key.replace('\r', '')
          private_key = private_key.replace('\n', '')
          if len(private_key) > 0:
              if private_key.find('-----BEGIN PRIVATE KEY-----') != -1:
                  private_key = private_key.replace('-----BEGIN PRIVATE KEY-----', '')
                  private_key = private_key.replace('-----END PRIVATE KEY-----', '')
                  private_key = private_key.replace(' ', '')
                  if heads:
                      private_key = "-----BEGIN PRIVATE KEY-----\n" + "\n".join(wrap(private_key, 64)) + "\n-----END PRIVATE KEY-----\n"
              else:
                  private_key = private_key.replace('-----BEGIN RSA PRIVATE KEY-----', '')
                  private_key = private_key.replace('-----END RSA PRIVATE KEY-----', '')
                  private_key = private_key.replace(' ', '')
                  if heads:
                      private_key = "-----BEGIN RSA PRIVATE KEY-----\n" + "\n".join(wrap(private_key, 64)) + "\n-----END RSA PRIVATE KEY-----\n"
          return private_key
docs: Returns a private key (adding header & footer if required).
  
          :param key A private key
          :type: string
  
          :param heads: True if we want to include head and footer
          :type: boolean
  
          :returns: Formated private key
          :rtype: string