Module bin.base

This module contains basic binary functions.

Info:

  • Release: v4

Functions

htobe16(x) Converts host byte order to big endian 16 bits.
htole16(x) Converts host byte order to little endian 16 bits.
be16toh(x) Converts big endian 16 bits to host byte order.
le16toh(x) Converts little endian 16 bits to host byte
htobe32(x) Converts host byte order to big endian 32 bits.
htole32(x) Converts host byte order to little endian 32 bits.
be32toh(x) Converts big endian 32 bits to host byte order.
le32toh(x) Converts little endian 32 bits to host byte
htobe64(x) Converts host byte order to big endian 64 bits.
htole64(x) Converts host byte order to little endian 64 bits.
be64toh(x) Converts big endian 64 bits to host byte order.
le64toh(x) Converts little endian 64 bits to host byte
hex(data, len) Returns hex representation of the binary data
xd(data, len) Returns hexdump (hexdump -C) of the binary data


Functions

Methods
htobe16(x)
Converts host byte order to big endian 16 bits.

Parameters:

  • x number
htole16(x)
Converts host byte order to little endian 16 bits.

Parameters:

  • x number
be16toh(x)
Converts big endian 16 bits to host byte order.

Parameters:

  • x number
le16toh(x)
Converts little endian 16 bits to host byte

Parameters:

  • x number
htobe32(x)
Converts host byte order to big endian 32 bits.

Parameters:

  • x number
htole32(x)
Converts host byte order to little endian 32 bits.

Parameters:

  • x number
be32toh(x)
Converts big endian 32 bits to host byte order.

Parameters:

  • x number
le32toh(x)
Converts little endian 32 bits to host byte

Parameters:

  • x number
htobe64(x)
Converts host byte order to big endian 64 bits.

Parameters:

  • x number
htole64(x)
Converts host byte order to little endian 64 bits.

Parameters:

  • x number
be64toh(x)
Converts big endian 64 bits to host byte order.

Parameters:

  • x number
le64toh(x)
Converts little endian 64 bits to host byte

Parameters:

  • x number
hex(data, len)
Returns hex representation of the binary data

Parameters:

  • data accepts string, allmost any pointer - start of the data.
  • len length of the data in bytes

Returns:

    string hex representation of the data

Usage:

    print(bin.hex "some binary string")
    736F6D652062696E61727920737472696E67
xd(data, len)
Returns hexdump (hexdump -C) of the binary data

Parameters:

  • data accepts string, allmost any pointer - start of the data.
  • len length of the data in bytes

Returns:

    string hexdump representation of the data

Usage:

    print(bin.xd "some binary string")
    [0000]   73 6F 6D 65  20 62 69 6E  61 72 79 20  73 74 72 69   some  bin ary  stri
    [0010]   6E 67                                                ng
generated by LDoc 1.4.6 Last updated 2022-05-19 12:17:27