Creates a C array from a hex-string or a stream of binary data.

Overview

hex2array-c

Creates a C array from a hex-string.

Usage

Usage: python3 hex2array_c.py HEX_STRING [-h|--help]
Use '-' to read the hex string from STDIN.

Examples:
    python3 hex2array_c.py '0x9d35 0x3f19 0xcf12 0xcd72 0x7f4f 0xa035 0xb307 0x8f07'
    python3 hex2array_c.py '9d-3f-cf-cd-7f-a0-b3-8f' -w4
    python3 hex2array_c.py '538aedc060db31f2d708893526817f619d909526906c1c3a2dca7c242cd0e433' -n 'some_data' -w16
    cat ./afilewithbinarydata | python3 hex2array_c.py - -s4 -w4
    head -c 32 /dev/urandom | python3 hex2array_c.py -

Options:
    -n, --array-name NAME       The name to give to the generated array. The default is 'data'.
    -a, --array-type TYPE       The data type of the generated array. The default is 'const char'.
    -w, --array-width WIDTH     The number of array elements per row. The default is '8'.
    -s, --byte-length LENGTH    The byte length of each array element. The default is '1'.
    -t, --size SIZE             Trim the input to the specified size.
    -e, --swap-endianness       Swap the byte ordering of the generated array. The default is 'False'.

https://github.com/neosophaux

Examples

Pass '-' to the program to read the hex string from stdin.

$ python3 hex2array_c.py '8eb3a4eca0cf603086e9791ca8b1b4ee67038cb96243b18fe43b86dd9a20c18a' -n 'test' -w2 -s4 -e
const char test[8] = {
    0xeca4b38e, 0x3060cfa0, // 0x00000000
    0x1c79e986, 0xeeb4b1a8, // 0x00000008
    0xb98c0367, 0x8fb14362, // 0x00000010
    0xdd863be4, 0x8ac1209a  // 0x00000018
};
$ python3 hex2array_c.py '8eb3a4eca0cf603086e9791ca8b1b4ee67038cb96243b18fe43b86dd9a20c18a' -w4 -a 'uint32_t'
uint32_t data[8] = {
    0x8eb3a4ec, 0xa0cf6030, 0x86e9791c, 0xa8b1b4ee, // 0x00000000
    0x67038cb9, 0x6243b18f, 0xe43b86dd, 0x9a20c18a  // 0x00000010
};
$ echo '0x9e 6b' | python3 hex2array_c.py - -n 'test' -e -s2 -a 'const uint16_t'
const uint16_t test[1] = {
    0x6b9e // 0x00000000
};
$ head -c 32 /dev/urandom | python3 hex2array_c.py -
const char data[32] = {
    0xbb, 0x70, 0xa1, 0x06, 0x1a, 0xe3, 0x85, 0x25, // 0x00000000
    0x6d, 0xbd, 0xeb, 0x73, 0x4d, 0x4b, 0x36, 0x85, // 0x00000008
    0x13, 0xb0, 0x61, 0xbc, 0x5f, 0x33, 0x68, 0x47, // 0x00000010
    0x2f, 0x6f, 0x37, 0x98, 0xce, 0xe4, 0x1c, 0x2b  // 0x00000018
};
Owner
John Doe
John Doe
Simple web index to use bloom filter for Pwned Passwords

pwbloom Simple web index to use bloom filter for Pwned Passwords The index.py runs a simple CGI web service checking passwords with a bloom filter for

Hanno Böck 4 Nov 23, 2021
A collection of custom scripts for working with Quake assets.

Custom Quake Tools A collection of custom scripts for working with Quake assets. Features Script to list all BSP files in a Quake mod

Jason Brownlee 3 Jul 05, 2022
A Python package for floating-point binary fractions. Do math in base 2!

An implementation of a floating-point binary fractions class and module in Python. Work with binary fractions and binary floats with ease!

10 Oct 29, 2022
Use generator for range function

Use the generator for the range function! installation method: pip install yrange How to use: First import yrange in your application. You can then wo

1 Oct 28, 2021
Set of scripts for some automation during Magic Lantern development

~kitor Magic Lantern scripts A few automation scripts I wrote to automate some things in my ML development efforts. Used only on Debian running over W

Kajetan Krykwiński 1 Jan 03, 2022
A tool to create the basics of a project

Project-Scheduler Instalação Para instalar o Project Maker, você necessita está em um ambiente de desenvolvimento Linux ou wsl com alguma distro debia

2 Dec 17, 2021
Numbers-parser - Python module for parsing Apple Numbers .numbers files

numbers-parser numbers-parser is a Python module for parsing Apple Numbers .numbers files. It supports Numbers files generated by Numbers version 10.3

Jon Connell 154 Jan 05, 2023
Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder

Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder

Gobinath 1.2k Jan 01, 2023
Extract XML from the OS X dictionaries.

Extract XML from the OS X dictionaries.

Joshua Olson 13 Dec 11, 2022
Script for generating Hearthstone card spoilers & checklists

This is a script for generating text spoilers and set checklists for Hearthstone. Installation & Running Python 3.6 or higher is required. Copy/clone

John T. Wodder II 1 Oct 11, 2022
A fast Python implementation of Ac Auto Mechine

A fast Python implementation of Ac Auto Mechine

Jin Zitian 1 Dec 07, 2021
Python implementation of Gorilla time series compression

Gorilla Time Series Compression This is an implementation (with some adaptations) of the compression algorithm described in section 4.1 (Time series c

Ghiles Meddour 19 Jan 01, 2023
Python Random Number Genrator

This Genrates Random Numbers. This Random Number Generator was made using python. This software uses Time and Random extension. Download the EXE file and run it to get your answer.

Krish Sethi 2 Feb 03, 2022
Password generator

Password generator technologies used What is? It is Password generator How to Download? Download on releases Clone repo git clone https://github.com/m

Miek 1 Nov 02, 2021
A quick username checker to see if a username is available on a list of assorted websites.

A quick username checker to see if a username is available on a list of assorted websites.

Maddie 4 Jan 04, 2022
Install, run, and update apps without root and only in your home directory

Qube Apps Install, run, and update apps in the private storage of a Qube Building instrutions

Micah Lee 26 Dec 27, 2022
Napari plugin for loading Bitplane Imaris files .ims

napari-imaris-loader Napari plugin for loading Bitplane Imaris files '.ims'. Notes: For this plugin to work "File/Preferences/Experimental/Render Imag

Alan Watson 4 Dec 01, 2022
convert a dict-list object from / to a typed object(class instance with type annotation)

objtyping 带类型定义的对象转换器 由来 Python不是强类型语言,开发人员没有给数据定义类型的习惯。这样虽然灵活,但处理复杂业务逻辑的时候却不够方便——缺乏类型检查可能导致很难发现错误,在IDE里编码时也没

Song Hui 15 Dec 22, 2022
A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt

Kerning A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt There are three stages of the algorithm. The first

Sayed Zeeshan Asghar 6 Aug 01, 2022
Python 3 script unpacking statically x86 CryptOne packer.

Python 3 script unpacking statically x86 CryptOne packer. CryptOne versions: 2021/08 until now (2021/12)

5 Feb 23, 2022