tlslite.utils.compat module

Miscellaneous functions to mask Python version differences.

tlslite.utils.compat.a2b_base64(s)[source]
tlslite.utils.compat.a2b_hex(s)[source]
tlslite.utils.compat.b2a_base64(b)[source]
tlslite.utils.compat.b2a_hex(b)[source]
tlslite.utils.compat.bit_length(val)[source]

Return number of bits necessary to represent an integer.

tlslite.utils.compat.byte_length(val)[source]

Return number of bytes necessary to represent an integer.

tlslite.utils.compat.bytes_to_int(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

tlslite.utils.compat.compat26Str(x)[source]
tlslite.utils.compat.compatAscii2Bytes(val)[source]

Convert ASCII string to bytes.

tlslite.utils.compat.compatHMAC(x)[source]

Convert bytes-like input to format acceptable for HMAC.

tlslite.utils.compat.compatLong(num)[source]
tlslite.utils.compat.compat_b2a(val)[source]

Convert an ASCII bytes string to string.

tlslite.utils.compat.formatExceptionTrace(e)[source]

Return exception information formatted as string

tlslite.utils.compat.int_to_bytes(val, length=None, byteorder='big')[source]

Return number converted to bytes

tlslite.utils.compat.raw_input(s)[source]
tlslite.utils.compat.readStdinBinary()[source]
tlslite.utils.compat.remove_whitespace(text)[source]

Removes all whitespace from passed in string

tlslite.utils.compat.time_stamp()[source]

Returns system time as a float