Skip to content

VakhoQ/tlv-encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tlv-encoder

TLV (tag-length-value) communication protocol implementation.

Requirements

  • Java version 1.8 or higher
  • maven 3.x or gradle 4.x

Build with maven

In order to build project with maven you should check out build-project-with-maven branch.

git checkout build-project-with-maven

run the following command in order to build project:

mvn package

Build with gradle

In order to build project with gradle you should check out master branch.

git checkout master

if you have gradle installed in your local machine run the following command:

gradle build

if you don't have gradle installed in your local machine, you can use gradle wrapper to build project.

./gradlew build

How to encode

TLVAbstractData numericTypeValue = new NumericTypeValue("key", 1);
TLVAbstractData stringTypeValue = new StringTypeValue("key", "value");
List<TLVAbstractData> input = Arrays.asList(numericTypeValue, stringTypeValue);
byte[] output = new TLVParserImpl().encode(input);

How to decode

byte [] stringTypeInput = new byte[]{5, 4, 77, 84, 73, 68, 2, 0, -48, 16};
byte [] numericTypeInput = new byte[]{1, 4, 77, 84, 73, 68, 1, 0, 1};
List<StringTypeValue> output = new TLVParserImpl().decode(stringTypeInput);
List<NumericTypeValue> output = new TLVParserImpl().decode(numericTypeInput);

You can see various encoding/decoding examples in Groovy test cases.

About

TLV (tag-length-value) communication protocol implementation in Java

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published