code: def tlsa_data(pub, usage, selector, matching):
      '''
      Generate a TLSA rec
      :param pub: Pub key in PEM format
      :param usage:
      :param selector:
      :param matching:
      :return: TLSA data portion
      '''
      usage = RFC.validate(usage, RFC.TLSA_USAGE)
      selector = RFC.validate(selector, RFC.TLSA_SELECT)
      matching = RFC.validate(matching, RFC.TLSA_MATCHING)
  
      pub = ssl.PEM_cert_to_DER_cert(pub.strip())
      if matching == 0:
          cert_fp = binascii.b2a_hex(pub)
      else:
          hasher = hashlib.new(RFC.TLSA_MATCHING[matching])
          hasher.update(
              pub
          )
          cert_fp = hasher.hexdigest()
  
      return _rec2data(usage, selector, matching, cert_fpf tlsa_data(pub, usage, selector, matching):
      '''
      Generate a TLSA rec
      :param pub: Pub key in PEM format
      :param usage:
      :param selector:
      :param matching:
      :return: TLSA data portion
      '''
      usage = RFC.validate(usage, RFC.TLSA_USAGE)
      selector = RFC.validate(selector, RFC.TLSA_SELECT)
      matching = RFC.validate(matching, RFC.TLSA_MATCHING)
  
      pub = ssl.PEM_cert_to_DER_cert(pub.strip())
      if matching == 0:
          cert_fp = binascii.b2a_hex(pub)
      else:
          hasher = hashlib.new(RFC.TLSA_MATCHING[matching])
          hasher.update(
              pub
          )
          cert_fp = hasher.hexdigest()
  
      return _rec2data(usage, selector, matching, cert_fp)
docs: Generate a TLSA rec
      :param pub: Pub key in PEM format
      :param usage:
      :param selector:
      :param matching:
      :return: TLSA data portion