In brief
binascii.hexlify(b'AB') gives b'4142', while unhexlify() performs the reverse conversion. This represents bytes; it neither compresses nor encrypts them.
Useful to know
binascii.hexlify(b'AB') gives b'4142', while unhexlify() performs the reverse conversion. This represents bytes; it neither compresses nor encrypts them. [1]
It helps inspect binary data when ordinary text output hides the contents. Check input format and length. An arbitrary readable string does not become valid hexadecimal merely because it is meant to contain an identifier.
Sources
For further detail and to check the information: