tlvToBase64 function
Converts a TLV encoded string to a Base64 encoded string.
The tlv
parameter is a string containing the TLV encoded data.
Returns the Base64 encoded representation of the TLV data.
Implementation
String tlvToBase64(String tlv) {
List<int> bytes = [];
for (int i = 0; i < tlv.length; i += 2) {
String hexStr = tlv.substring(i, i + 2);
int byte = int.parse(hexStr, radix: 16);
bytes.add(byte);
}
return base64Encode(Uint8List.fromList(bytes));
}