def asciiHexDecode(stream):
 eod = '>'
 decodedStream = ''
 char = ''
 index = 0
 while (index < len(stream)):
  c = stream[index]
  if (c == eod):
   if ((len(decodedStream) % 2) != 0):
    char += '0'
    try:
     decodedStream += chr(int(char, base=16))
    except:
     return ((-1), 'Error in hexadecimal conversion')
   break
  elif c.isspace():
   index += 1
   continue
  char += c
  if (len(char) == 2):
   try:
    decodedStream += chr(int(char, base=16))
   except:
    return ((-1), 'Error in hexadecimal conversion')
   char = ''
  index += 1
 return (0, decodedStream)

def asciiHexDecode ( stream ) : eod = '>' decodedStream = '' char = '' index = 0 while ( index < len ( stream ) ) : c = stream [ index ] if ( c == eod ) : if ( ( len ( decodedStream ) % 2 ) != 0 ) : char += '0' try : decodedStream += chr ( int ( char , base = 16 ) ) except : return ( ( - 1 ) , 'Error in hexadecimal conversion' ) break elif c . isspace ( ) : index += 1 continue char += c if ( len ( char ) == 2 ) : try : decodedStream += chr ( int ( char , base = 16 ) ) except : return ( ( - 1 ) , 'Error in hexadecimal conversion' ) char = '' index += 1 return ( 0 , decodedStream )
method to decode streams using hexadecimal encoding .