https://github.com/bfontaine/dz
Dead simple hex2bin CLI tool
https://github.com/bfontaine/dz
hexadecimal ruby tool
Last synced: about 1 year ago
JSON representation
Dead simple hex2bin CLI tool
- Host: GitHub
- URL: https://github.com/bfontaine/dz
- Owner: bfontaine
- License: mit
- Created: 2013-10-29T23:08:02.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-02-02T21:30:03.000Z (over 12 years ago)
- Last Synced: 2025-03-23T23:43:40.146Z (over 1 year ago)
- Topics: hexadecimal, ruby, tool
- Language: Ruby
- Size: 148 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dz
[](https://travis-ci.org/bfontaine/dz)
[](http://badge.fury.io/rb/dz)
[](https://coveralls.io/r/bfontaine/dz)
[](https://gemnasium.com/bfontaine/dz)
**dz** is a dead simple hexadecimal-to-binary tool. It’s handy to create
binaries by hand (yeah, some people do that).
## Install
```
gem install dz
```
## Usage
```
$ dz input.dz output
```
Give it two filenames. It’ll read the first one and write binary data into the
second one. That’s it!
Okay, one more thing: if you give `-` for the input, it'll read on stdin, and if
you give more than two files, it'll assume that the last one is the output and
all the others are parts of the input. So,
```sh
dz input{1,2,3}.dz output.bin
```
is equivalent to:
```sh
cat input{1,2,3}.dz | dz - output.bin
```
### Syntax
I use `.dz` for input files but you can use what you want, they are plain text
files.
Each byte is written as an hexadecimal number. Two bytes must be separated by
one or more spaces and/or newlines. Comments start with a `#` and take the whole
line. Non-hexadecimal chars (outside of comments) are ignored.
#### Example
```
# file header
34 | 00 | 0A 0A
# first part
01 | 00 | 00 00 02 | AA AF
# second part
01 | 0F | 00 00 06 | AA CC 89 3B 01 79
```
Save this in `example.dz`, then run:
```
$ dz example.dz example
```
you can now check the binary using `hexdump`:
```
$ hexdump example
0000000 34 00 0a 0a 01 00 00 00 02 aa af 01 0f 00 00 06
0000010 aa cc 89 3b 01 79
0000016
```
## Tests
```
$ git clone https://github.com/bfontaine/dz.git
$ cd dz
$ bundle install
$ bundle exec rake test
```
It’ll generate a `coverage/index.html`, which you can open in a Web browser.