Base16 Encoding Utility is a small but useful console application for MS Windows operating system that allows you to convert your data using Base16 encoding and provides additional tools to manage the formatting of the hex dump output. Application input can be obtained from files, command line, keyboard or by redirecting output from another console application.
The Base16 algorithm provides encoding in such a way that each byte of data is split into two 4-bit values and represented by two hexadecimal digits.
Also, this utility can restore the original data from text containing a hex dump.
Microsoft Windows XP (or later) operating system with Microsoft .NET Framework 4.0 installed.
✔️ Encode data.
✔️ Decode hex dumps.
✔️ Read files, text input or redirected output from console apps.
✔️ Write result to file or console window.
✔️ Convert data to array declarations for common languages.
This utility must be called from the command line with the specified arguments:
base16 [-e|-d] [-s] [-delimiter char] [-prefix prestr] [-postfix poststr] [-header hstr] [-footer fstr] [-l] [-w width] [-sfx] [-c] [-o outfile] [-f] file1 [file2...] [-t text] [-i]
Key | Specification |
---|---|
-e | Encode data. This is default choise. |
-d | Decode data. |
Key | Specification |
---|---|
-s or -space | Group bytes in the output with spaces. |
-delimiter {char} | Use the specified delimiter char instead spaces. Can be used instead -s key. |
-prefix {string} | Use the specified prefix string for every byte. This parameter is sensitive to escape characters. |
-postfix {string} | Use the specified postfix string for every byte except the last item. This parameter is sensitive to escape characters. |
-header {string} | Use the specified header string before output data. This parameter is sensitive to escape characters. |
-footer {string} | Use the specified footer string after output data. This parameter is sensitive to escape characters. |
-l or -lcase | Convert output to lowercase. |
-w {width} or -wrap {width} | Split the specified number of characters into lines. A value of this parameter less than 2 will be ignored. By default, the output will not wrap. |
-sfx | Write a special command lines before the encoded data to create a self-extracting batch file. Items such as -s, -prefix, -postfix and -delimiter will be ignored. |
-c | Create an array declaration for a C-like language. Items such as -s, -prefix, -postfix and -delimiter will be ignored. |
-cs | Create an array declaration for a C# language. Items such as -s, -prefix, -postfix and -delimiter will be ignored. |
-vb | Create an array declaration for a Visual Basic language. Items such as -s, -prefix, -postfix and -delimiter will be ignored. |
Key | Specification |
---|---|
-o or -output {outfile} | Set output to file {outfile}. If parameter is omitted, program's output will be redirected to the console window. |
{file1} {file2} ... | Input files containing data to be encoded. |
-f {value as file name} or -file {value as file name} | Force use value as input filename (to escape parameters). If input files is omitted, program's input will be redirected to the standard input. Instead of a file name, you can specify a directory and file mask to search for files. |
-t {text for encoding/decoding} or -text {text for encoding/decoding} | Use typed text value instead of input. This stuff should be after all other arguments. |
-i or -input | Read data from standard input device until Ctrl+C pressed. All listed files or key -t will be ignored. |
base16 file1.txt
Will display encoded data of file "file1.txt".
base16 file1.txt > file2.txt
or
base16 file1.txt -o file2.txt
Will save encoded data from "file1.txt" to "file2.txt".
base16 -s file1.txt -o file2.txt
Will save encoded data from file "file1.txt" to output "file2.txt", separated by bytes.
echo Foo | base16 -s
Will display: 46 6F 6F 20 0D 0A.
echo Bar | base16 -s -prefix 0x -postfix ,
Will display: 0x42, 0x61, 0x72, 0x20, 0x0D, 0x0A.
base16 -t Hello, world!
Will display: 48656C6C6F2C20776F726C6421.
base16 -i
Will input data from the keyboard and encode it.
echo 42 61 72 | base16 -d
or
base16 -d -t 42 61 72
Will display: Bar.
base16 -s -w 16 -l -delimiter ; test.txt
Will display the encoded content of the file "test.txt" with a custom separator ";" between bytes.
type encoded.txt | base16 -d > original.txt
or
base16 -d encoded.txt -o original.txt
Will output the decoded content of the file "encoded.txt" to a new file "original.txt".
base16 -c bytes -t Hello, world
Will display array declare:
unsigned char *bytes = unsigned char[]
{
0x73, 0x20, 0x2D, 0x74, 0x20, 0x48, 0x65, 0x6C,
0x6C, 0x6F, 0x2C, 0x20, 0x77, 0x6F, 0x72, 0x6C,
0x64
}
If you type "base16 -c -t Hello, world | clip", this ad will be stored to the clipboard immediately.
base16 -sfx -o hello.bat -t Hello, world
Will store encoded text into self-extracting batch file "hello.bat".
The content of batch file "hello.bat" looks like this:
:BEGIN
@ECHO OFF
SET /P filename="Enter filename: "
SET tmpfile=%~d0%~p0%RANDOM%.tmp
SET outfile=%~d0%~p0%filename%
ECHO tmpfile = %tmpfile%
ECHO outfile = %outfile%
FINDSTR "^[0-9A-F][0-9A-F][^\s]" %0 > "%tmpfile%"
certutil -decodehex "%tmpfile%" "%outfile%"
TIMEOUT 3
DEL /F /Q "%tmpfile%" %0
EXIT
48 65 6C 6C 6F 2C 20 77 6F 72 6C 64
If you run "hello.bat", this script will ask for a filename and write "Hello, world" to it.