Skip to main content

Description

Basic tools to read, format, filter and display hex values

Installation

pip install hexlib

Usage

  • The class HexTwin is a hexadecimal representation of a file
    • HexTwin reads a file in 16 byte chunks
    • Each of this chunks is saved as as tuple together with the following information:
      • tuple[0] = Offset
      • tuple[1] = A bytearray containing the 16 bytes
      • tuple[2] = A boolean indicating if the bytes are all zero
      • tuple[3] = A boolean indicating if the bytes are all non ASCII values
  • The class Hexdump format and prints HexTwin instances

Example

from hexlib.HexTwin import HexTwin
from hexlib.Hexdump import Hexdump

# 1.) HexTwin instance
twin = HexTwin("path/to/file/test.txt")
dump = Hexdump()

# Activates filtering for zero rows
dump.filter(filterZeroRows=True) 
dump.printTwin("path/to/result.txt", twin)

# Activates filtering for non-ascii rows (Includes also zero rows)
dump.filter(filterNonAsciiRows=True) 
dump.printTwin("path/to/result.txt", twin)

# 2.) Create HexTwin from bytes (Filtering can also be used here)
f = open("path/to/file", "rb")
twinFromBytes = HexTwin.fromBytes(f.read(16))
dumpFromBytes = Hexdump()

dumpfromBytes.printTwin("path/to/bytes-result.txt", twinFromBytes)

# 3.) Create a HexTwin from a offset reading x bytes (Filtering can also be used here)
twinFromOffset = HexTwin.fromOffset("path/to/file.txt", offset=50, noOfBytes=10)
dumpFromOffset = Hexdump()

dumpFromOffset.printTwin("path/to/offset-result.txt", twinFromOffset)

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hexlib-2.0.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hexlib-2.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file hexlib-2.0.3.tar.gz.

File metadata

  • Download URL: hexlib-2.0.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for hexlib-2.0.3.tar.gz
Algorithm Hash digest
SHA256 abb9e3a7ba1754e86ee91909dea2b37ef244ca8d6b73ecd03c55042f4d96b27d
MD5 05614f5abbc19ca98e991ec0a61da387
BLAKE2b-256 0cc9897d14811ebf507d2fdecd02ab39778a5d9bacec7168f0e1d0d0f4f816f5

See more details on using hashes here.

File details

Details for the file hexlib-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: hexlib-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for hexlib-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b23aacd790ee34729382e6a650b60b09e48f35beafdd60393e8c3f35c0a565e
MD5 b4de18745d3dee0f0838b0ecaa81ec4d
BLAKE2b-256 9e361d742cbc8039fadd9d1e07a1435d54bd49fce4376389f3b9d1d9066093f7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page