ubinascii
– Binary / ASCII conversion¶
This module implements the corresponding CPython A subset of modules, as follows. See CPython document for details: binascii
This module realizes the conversion (bidirectional) between binary data and various ASCII codes.
Function¶
-
ubinascii.
hexlify
(data[, sep])¶ Converts a string to a hexadecimal representation.
differences with CPython
If additional parameter SEP is provided, It will be used as a separator in-between these hexadecimal values.
Without SEP parameter:
>>> ubinascii.hexlify('\x11\x22123') b'1122313233' >>> ubinascii.hexlify('abcdfg') b'616263646667'
If the second parameter SEP is specified, it will be used to separate two hexadecimal numbers:
>>> ubinascii.hexlify('\x11\x22123', ' ') b'11 22 31 32 33' >>> ubinascii.hexlify('\x11\x22123', ',') b'11,22,31,32,33'
-
ubinascii.
unhexlify
(data)¶ Convert hexadecimal string to binary string, the function is opposite to hexlify.
Example:
>>> ubinascii.unhexlify('313233') b'123'
-
ubinascii.
a2b_base64
(data)¶ ecode Base64 encoded data, ignoring invalid characters in input. According with RFC 2045 s.6.8 。returns a
bytes
object。