BER-TLV parser and builder
BerTlv is a java library for parsing and building BER TLV encoded data.
Features
- supported types: amount, date, time, text, BCD, bytes
- thread safe (provides immutable container BerTlv)
- production ready (uses in several projects)
- lightweight (no external dependencies)
Setup with dependency managers
Maven
<dependency>
<groupId>com.payneteasy</groupId>
<artifactId>ber-tlv</artifactId>
<version>1.0-11</version>
</dependency>
Gradle
implementation 'com.payneteasy:ber-tlv:1.0-11'
How to parse
byte[] bytes = HexUtil.parseHex("50045649534157131000023100000033D44122011003400000481F");
BerTlvParser parser = new BerTlvParser(LOG);
BerTlvs tlvs = parser.parse(bytes, 0, bytes.length);
BerTlvLogger.log(" ", tlvs, LOG);
How to build
byte[] bytes = new BerTlvBuilder()
.addHex(new BerTag(0x50), "56495341")
.addHex(new BerTag(0x57), "1000023100000033D44122011003400000481F")
.buildArray();
License
The BerTlv framework is licensed under the Apache License 2.0