Hello, I have this code in vb net
Outputs :
AQRURVNUAg8zMDAyNTQyMzU0NTg0NTYDFDIwMjQtMDItMTdUMDM6MDA6NDJaBAMxMDAFAjE1
010454455354020F3330303235343233353435383435360314323032342D30322D31375430333A30303A34325A040331303005023135
How can it be converted to B4A
The code depends on five variables that I want to deal with inside B4A
B4X:
Public Function encodeQrText(ByVal sallerName As String, ByVal sallerTRN As String, ByVal invoiceDateTime As String, ByVal totalWithVAT As String, ByVal VATTotal As String) As String
Dim bytes As Byte() = Encoding.UTF8.GetBytes(sallerName)
Dim L1 As String = bytes.Length.ToString("X")
Dim tag1Hex As String = BitConverter.ToString(bytes)
tag1Hex = tag1Hex.Replace("-", "")
Dim L2 As String = sallerTRN.Length.ToString("X")
Dim L3 As String = invoiceDateTime.Length.ToString("X")
Dim L4 As String = totalWithVAT.Length.ToString("X")
Dim L5 As String = VATTotal.Length.ToString("X")
Dim hex As String = "01" & (If((L1.Length = 1), ("0" & L1), L1)) & tag1Hex & "02" & (If((L2.Length = 1), ("0" & L2), L2)) & ToHexString(sallerTRN) & "03" & (If((L3.Length = 1), ("0" & L3), L3)) + ToHexString(invoiceDateTime) & "04" & (If((L4.Length = 1), ("0" & L4), L4)) + ToHexString(totalWithVAT) & "05" & (If((L5.Length = 1), ("0" & L5), L5)) + ToHexString(VATTotal)
Texthex.Text = hex
Return HexToBase64(hex)
End Function
B4X:
Private Function HexToBase64(ByVal strInput As String) As String
Try
Dim bytes = New Byte(strInput.Length / 2 - 1) {}
For i = 0 To bytes.Length - 1
bytes(i) = Convert.ToByte(strInput.Substring(i * 2, 2), 16)
Next
Return Convert.ToBase64String(bytes)
Catch __unusedException1__ As Exception
Return "-1"
End Try
End Function
Outputs :
AQRURVNUAg8zMDAyNTQyMzU0NTg0NTYDFDIwMjQtMDItMTdUMDM6MDA6NDJaBAMxMDAFAjE1
010454455354020F3330303235343233353435383435360314323032342D30322D31375430333A30303A34325A040331303005023135
How can it be converted to B4A
The code depends on five variables that I want to deal with inside B4A