def asciiHexEncode(stream):
 try:
  encodedStream = stream.encode('hex')
 except:
  return ((-1), 'Error in hexadecimal conversion')
 return (0, encodedStream)

def asciiHexEncode ( stream ) : try : encodedStream = stream . encode ( 'hex' ) except : return ( ( - 1 ) , 'Error in hexadecimal conversion' ) return ( 0 , encodedStream )
method to encode streams using hexadecimal encoding .