def _base64_to_hex(identity, check_if_fingerprint=True):
 missing_padding = (len(identity) % 4)
 identity += ('=' * missing_padding)
 try:
  identity_decoded = base64.b64decode(stem.util.str_tools._to_bytes(identity))
 except (TypeError, binascii.Error):
  raise ValueError(("Unable to decode identity string '%s'" % identity))
 fingerprint = binascii.b2a_hex(identity_decoded).upper()
 if stem.prereq.is_python_3():
  fingerprint = stem.util.str_tools._to_unicode(fingerprint)
 if check_if_fingerprint:
  if (not stem.util.tor_tools.is_valid_fingerprint(fingerprint)):
   raise ValueError(("Decoded '%s' to be '%s', which isn't a valid fingerprint" % (identity, fingerprint)))
 return fingerprint

def _base64_to_hex ( identity , check_if_fingerprint = True ) : missing_padding = ( len ( identity ) % 4 ) identity += ( '=' * missing_padding ) try : identity_decoded = base64 . b64decode ( stem . util . str_tools . _to_bytes ( identity ) ) except ( TypeError , binascii . Error ) : raise ValueError ( ( "Unable to decode identity string '%s'" % identity ) ) fingerprint = binascii . b2a_hex ( identity_decoded ) . upper ( ) if stem . prereq . is_python_3 ( ) : fingerprint = stem . util . str_tools . _to_unicode ( fingerprint ) if check_if_fingerprint : if ( not stem . util . tor_tools . is_valid_fingerprint ( fingerprint ) ) : raise ValueError ( ( "Decoded '%s' to be '%s', which isn't a valid fingerprint" % ( identity , fingerprint ) ) ) return fingerprint
decodes a base64 value to hex .