This is the B4J code excluding the inline Java code:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
#AdditionalJar: bcprov-jdk16-1.43
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Dim su As StringUtils
Dim dl As String = ""
Dim nativeMe As JavaObject
Private TextArea1 As TextArea
Private Button1 As Button
Private ListView1 As ListView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
nativeMe = Me
TextArea1.Text = "019b0945000060e9a27a1e475f89af17cb3a5ae86bd91152d22fbca1f462ba8bd39e9341bb26ad82e3ab1b4e68069247b75286edb64fed476c1a444bba7ffeca8ac9ddcf629ac582a865b8eefec682f33de40e68a6fc08265df86ad058376db56e4a9d2a2da285d11f408493fb4706abc346632a156b517c87b58372a3afda8be11dbae4a8f5a3d1881559ce0c69acd026770fd9e75c28c4abd0b2796e70eca894d8546bd8456bdcd9af0aa112f78b56523471b46805ae844a66108ba2f12a28180e5ddded48436239eae212c6193d351201e6a24613d2482ddae552bf7e21729246667a9cd5c730ba4b80736586f5f90894b1017fcea7b299cd6241a266c4b7b28b704de1f0266025358d134686e1cac2ba9af74ea16b9524f4fca20792d2618beec8499dbab596f5a56531f26462c996dad5e1278400a5266c5b5aed2dd3cae135821148bdfd3d564ac127c90d3a125031cb263e63879dfdd10725dc80225a700e5d259a5a1d2340d7bd2d3fecc9b078e1726661e2c51b945b56d762fa3067f2b926dd2707a74e1535abf1a7ee09b0ec40689cd3b3b9995dfdda9b5f33482f1441afa48304a68b24b942464d0334d4b20c17a6f09d5db119257212f7b2d48860e22c64924dc53c03557624a020b175ef47553946ce2e60c3f2ba95865d73b2d440c2fd3eb3c9850447c249c869444dbc103d8197c5556355e6c46455b61aa0b176bcc73290b532726d4339bb35b144fecf5c5d4c5e90aef23fc9c9375ae7206f9ea5a22255365f7e0728e3360cb78562c805a4f9a2b4a674eb5af30b598b98b16227a223505e2e013e426296e8f3d1ff03d6506fa431162438afabbc4e8b9626e8821d6bd264ff9d35a2df90e2be27e0297c162a0a6bbc937f349d31413484b52ca27255b2263abde2793cb946387685de9662777cdf6808a18c3a25759ed4e6ab6410f7881b655421be87e3f3df100062f12ae806059ca3e11248557080a64e4ec6e0a46697cae4c5c5197e3defdc"
End Sub
Private Sub Button1_Click
Dim ss As String
ss = TextArea1.Text.Trim
ListView1.Items.Clear
Log("ss = " & ss)
Log("ss length = " & ss.Length)
Dim block1 As String = ss.SubString2(10,268)
Dim conv As ByteConverter
Dim mybyte() As Byte = conv.HexToBytes(block1)
Log("MYSTRING LENGTH = " & block1.Length)
Dim returnedstring As String
returnedstring = nativeMe.RunMethod("decodeVersion2First5Blocks", Array(mybyte))
Dim MyBase64String As String = returnedstring
Dim MyBase64StringAsBytes() As Byte = su.DecodeBase64(MyBase64String)
Log("LENGTE = " & MyBase64StringAsBytes.Length)
Dim s As String = BytesToString(MyBase64StringAsBytes, 0, MyBase64StringAsBytes.Length, "ISO8859_1")
Dim karak(128) As String
Dim finalstring As String = ""
For i = 0 To s.Length - 1
Dim c As Char = s.CharAt(i)
Dim ub As Int = Bit.And(0xff, MyBase64StringAsBytes(i))
karak(i) = Bit.ToHexString(ub)
If karak(i).Length = 1 Then karak(i) = "0" & karak(i)
finalstring = finalstring & karak(i)
Log("char = " & c & " karak = " & karak(i) & " MyBase64StringAsBytes(" & i & ") = " & karak(i))
Next
Dim section1_length As Int = Bit.ParseInt(karak(10), 16)
Dim section2_length As Int = Bit.ParseInt(karak(12), 16)
Dim section1 As String = ""
For i = 15 To (15 + section1_length)
If karak(i).Trim = "e0" Then
karak(i) = ","
section1 = section1 & karak(i)
else if karak(i).Trim = "e1" Then
karak(i) = "[]"
section1 = section1 & karak(i)
Else
Dim c As Char = s.CharAt(i)
section1 = section1 & c
End If
Next
section1 = section1
Log("section1 = " & section1)
section1 = section1.Replace("[][][]", ",,,,")
section1 = section1.Replace("[][]", ",,,")
section1 = section1.Replace("[]", ",,")
Log("section1 = " & section1)
Dim headings() As String = Array As String("License type 1: ", "License type 2: ", "License Type 3: ", "License Type 4: ", _
"Surname: ", "Initials: ", "PrDP Code: ", "ID Country of Issue: ", "License Country of Issue: ", _
"Vehicle Restriction L1: ", "Vehicle Restriction L2: ", "Vehicle Restriction L3: ", "Vehicle Restriction L4: ", _
"License Number: ", "ID Number: ")
DateTime.DateFormat = "yyyy/MM/dd"
ListView1.Items.Add("Date: " & DateTime.Date(DateTime.Now))
ListView1.Items.Add("Time: " & DateTime.Time(DateTime.Now))
Dim Lines() As String = Regex.Split(",",section1)
For i = 0 To Lines.Length - 1
ListView1.Items.Add(headings(i) & Lines(i))
Log(""& headings(i) & " " & Lines(i))
Next
Dim section2 As String = ""
For i = (15 + section1_length) To (15 + section1_length + section2_length - 1)
If i = 15 + section1_length Then
section2 = section2 & karak(i).Trim
End If
If i > 15 + section1_length Then
If karak(i).Trim.SubString2(0,1) = "a" Then
section2 = section2 & "."
Else
section2 = section2 & karak(i).Trim.SubString2(0,1)
End If
If karak(i).Trim.SubString2(1,2) = "a" Then
section2 = section2 & "."
Else
section2 = section2 & karak(i).Trim.SubString2(1,2)
End If
End If
Next
If section2.EndsWith(".") = True Then
section2 = section2.SubString2(0, section2.Length - 1)
End If
Dim amendedSection2 As String = ""
For i = 0 To section2.Length - 1
If section2.SubString2(i, i+1) <> "." Then
amendedSection2 = amendedSection2 & section2.SubString2(i, i+1)
Else
amendedSection2 = amendedSection2 & "........"
End If
Next
Dim idType As String = amendedSection2.SubString2(0,2)
Dim issueDate1 As String = amendedSection2.SubString2(2, 10)
Dim issueDate2 As String = amendedSection2.SubString2(10,18)
Dim issueDate3 As String = amendedSection2.SubString2(18, 26)
Dim issueDate4 As String = amendedSection2.SubString2(26, 34)
Dim driverRestrictions As String = amendedSection2.SubString2(34, 36)
Dim PrDPdate As String = amendedSection2.SubString2(36, 44)
Dim licenseIssueNumber As String = amendedSection2.SubString2(44, 46)
Dim birthDate As String = amendedSection2.SubString2(46, 54)
Dim validFrom As String = amendedSection2.SubString2(54, 62)
Dim validTo As String = amendedSection2.SubString2(62, 70)
Dim gender As String = amendedSection2.SubString2(70, 72)
ListView1.Items.Add("ID Number Type: " & idType)
Log("ID Number Type: " & idType)
ListView1.Items.Add("Issue Date L1: " & issueDate1)
Log("Issue Date L1: " & issueDate1)
ListView1.Items.Add("Issue Date L2: " & issueDate2)
Log("Issue Date L2: " & issueDate2)
ListView1.Items.Add("Issue Date L3: " & issueDate3)
Log("Issue Date L3: " & issueDate3)
ListView1.Items.Add("Issue Date L4: " & issueDate4)
Log("Issue Date L4: " & issueDate4)
ListView1.Items.Add("Driver Restrictions: " & driverRestrictions)
Log("Driver Restrictions: " & driverRestrictions)
ListView1.Items.Add("PrDP Expiry Date: " & PrDPdate)
Log("PrDP Expiry Date: " & PrDPdate)
ListView1.Items.Add("License Issue Number: " & licenseIssueNumber)
Log("License Issue Number: " & licenseIssueNumber)
ListView1.Items.Add("Birth Date: " & birthDate)
Log("Birth Date: " & birthDate)
ListView1.Items.Add("Valid From: " & validFrom)
Log("Valid From: " & validFrom)
ListView1.Items.Add("Valid To: " & validTo)
Log("Valid To: " & validTo)
If gender = "01" Then gender = "Male" Else gender = "Female"
ListView1.Items.Add("Gender: " & gender)
Log("Gender: " & gender)
End Sub