Used to turn hexlify() into hex string.

    Does nothing in Python 2, but is necessary for Python 3, so that
    all inputs and outputs are always the same encoding.  Most of the
    time it doesn't matter, but some functions in Python 3 brick when
    they get bytes instead of a string, so it's safer to just
    strlify() everything.

    In Python 3 for example (examples commented out for doctest):
#   >>> hexlify(unhexlify("a1b2c3"))
    b'a1b2c3'
#   >>> b'a1b2c3' == 'a1b2c3'
    False
#   >>> strlify(hexlify(unhexlify("a1b2c3")))
    'a1b2c3'

    Whereas in Python 2, the results would be:
#   >>> hexlify(unhexlify("a1b2c3"))
    'a1b2c3'
#   >>> b'a1b2c3' == 'a1b2c3'
    True
#   >>> strlify(hexlify(unhexlify("a1b2c3")))
    'a1b2c3'

    Safe to use redundantly on hex and base64 that may or may not be
    byte objects, as well as base58, since hex and base64 and base58
    strings will never have "b'" in the middle of them.

    Obviously it's NOT safe to use on random strings which might have
    "b'" in the middle of the string.

    Use this for making sure base 16/58/64 objects are in string
    format.

    Use normalize_input() below to convert unicode objects back to
    ascii strings when possible.

def strlify(a):
    '''
    Used to turn hexlify() into hex string.

    Does nothing in Python 2, but is necessary for Python 3, so that
    all inputs and outputs are always the same encoding.  Most of the
    time it doesn't matter, but some functions in Python 3 brick when
    they get bytes instead of a string, so it's safer to just
    strlify() everything.

    In Python 3 for example (examples commented out for doctest):
#   >>> hexlify(unhexlify("a1b2c3"))
    b'a1b2c3'
#   >>> b'a1b2c3' == 'a1b2c3'
    False
#   >>> strlify(hexlify(unhexlify("a1b2c3")))
    'a1b2c3'

    Whereas in Python 2, the results would be:
#   >>> hexlify(unhexlify("a1b2c3"))
    'a1b2c3'
#   >>> b'a1b2c3' == 'a1b2c3'
    True
#   >>> strlify(hexlify(unhexlify("a1b2c3")))
    'a1b2c3'

    Safe to use redundantly on hex and base64 that may or may not be
    byte objects, as well as base58, since hex and base64 and base58
    strings will never have "b'" in the middle of them.

    Obviously it's NOT safe to use on random strings which might have
    "b'" in the middle of the string.

    Use this for making sure base 16/58/64 objects are in string
    format.

    Use normalize_input() below to convert unicode objects back to
    ascii strings when possible.
    '''

    if a == b'b' or a == 'b':
        return 'b'

    return str(a).rstrip("'").replace("b'","",1).replace("'","")