Skip to main content
Omnitracs Knowledge Base

Binary Payload Encoding and Decoding

Purpose:

This page contains a utility written in java to help convert binary data (encoding) into hex base 64. This allows for binary data to be included in xml. This tool also allows one to decode a hex base 64 data back into its binary form.

 

Assumptions:

Must have latest Java 1.6 version installed.

 

Artifacts:

ProjectSource

RuntimeJar

 

How To Use:

The utility takes a file input with the -f argument option. Additionally you need to pass in one of 2 argument options: -e or -d in order to

Here are the options:

[ -f ] to pass in a file (full directory path)

[ -e ] to encode from binary to hex

[ -d ] to decode from hex to binary

The result of the program is another file that is named for the encoding or decoding operation: so if the input file is: temp.bin then the output file is: Encoded_temp.bin

 

Example:

The following example takes a file temp.bin (with binary data) and encodes it into a hex data file named:  Encoded_temp.bin

java -jar HexCoder-0.0.1-SNAPSHOT-jar-with-dependencies.jar -f /Users/mark/Dev/ws/junoWS/HexCoder/temp.bin -e
 

 

Command line output:

Encoding:

 

Reading Input File:

temp.bin

 

Raw Byte Input:

q?????????????????????T??????

 

Data Length:

29

 

Hex Output:

71c39dc39dc388c39dc3ab3fc3b8c3b1c392c3afc3af54c395c3bfc2a3

 

Data Length:

58

 

Writing Output File:

Encoded_temp.bin

 

Successful

  • Was this article helpful?