Skip to content

Keidan/hex2bin

Repository files navigation

hex2bin

Linux CI Windows CI Release License: GPL v3 Bugs Code Smells Duplicated Lines (%) Vulnerabilities Maintainability Rating Reliability Rating Security Rating Technical Debt Lines of Code Coverage Quality Gate Status

(GPL) Hex to binary converter.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.

Instructions

MS Windows

On MS Windows, you'll need to install MS Visual Studio build tools.

To do this, you can use the following commands (open powershell as administrator):

Installation of Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Installation of Python, Ninja and MS Visual Studio build tools :

choco install python3 ninja visualstudio2022buildtools

GNU Linux

On GNU Linux, you'll need to install CMake and Ninja.

sudo apt-get install cmake ninja-build

Download

mkdir devel
cd devel
git clone https://github.com/Keidan/hex2bin.git
cd hex2bin

Build

MS Windows

cmake -S . -B build -DCMAKE_BUILD_TYPE=release -G"Visual Studio 17 2022"
cmake --build build

GNU Linux

cmake -S . -B build -DCMAKE_BUILD_TYPE=release -G"Ninja"
cmake --build build

VSCode

An MS VSCode workspace file can be found at the following location .vscode/hex2bin.code-workspace

CMake options

* Supported distrib.: -DDISTRIBUTION=[debug|release]
* Supported distrib.: -DCMAKE_BUILD_TYPE=[debug|release]
* Default start value: cmake -DDEFSTART=[int value] (see the '-s, --start' option of the binary)
* Default limit value: cmake -DDEFLIMIT=[int value] (see the '-l, --limit' option of the binary)
* Default width value: cmake -DDEFWIDTH=[int value] (see the '--width' option of the binary)

You can also use cmake-gui to manage the options.

Example (with cmake -DDEFSTART=0 -DDEFLIMIT=0)

For Windows, remember to add .exe after the binary name.

Note: The limit, start, offset, length, width, linear arguments can be expressed in decimal or hexadecimal if they start with 0x.

Test 1:

hex2bin -i sample1.txt -o sample1.txt.new -s 6 -l 47

hex2bin -i sample1.txt.new -o sample1.txt.bin -p

Test 2:

hex2bin -i sample2.txt -o sample2.txt.new -l 47

hex2bin -i sample2.txt.new -o sample2.txt.bin -p

Test 3:

hex2bin -i sample3.txt -o sample3.txt.new -s 1

Test 4:

hex2bin -i sample1.hex -o sample.bin.new --ihex h2b

Test 5:

hex2bin -i sample1.hex -o sample.bin.new --ihex h2b --offset 0x080002c5

Test 6:

hex2bin -i sample1.hex -o sample.bin.new --ihex b2h

Test 7:

hex2bin -i sample1.hex -o sample.bin.new --ihex b2h --offset 0x08000000

Test 8:

hex2bin -i sample1.hex -o sample.bin.new --ihex b2h --offset 0x08000000 --linear 0x080002c5

Test 9:

hex2bin -i sample2.bin -o sample.hex.new --ihex b2h --offset 0x08000000 --linear 0x080002c5 --padding_width 0x20

License

GNU GPL v3 or later