def str2hex(value, prefix='', glue=u'', format='%02X'):
 if isinstance(glue, str):
  glue = unicode(glue)
 if (0 < len(prefix)):
  text = [prefix]
 else:
  text = []
 for character in value:
  text.append((format % ord(character)))
 return glue.join(text)

def str2hex ( value , prefix = '' , glue = u'' , format = '%02X' ) : if isinstance ( glue , str ) : glue = unicode ( glue ) if ( 0 < len ( prefix ) ) : text = [ prefix ] else : text = [ ] for character in value : text . append ( ( format % ord ( character ) ) ) return glue . join ( text )
convert a string to hex encoded format .