I need help to convert a function from vba to B4j code
How would you convert the following function?
How would you convert the following function?
B4X:
Function decrypt(ByVal key As String, ByVal src As String) As String
Dim KeyPos As Integer, KeyLen As Integer, SrcAsc As Integer, dest As String, offset As Integer, TmpSrcAsc, SrcPos
KeyLen = Len(key)
offset = Val("&H" + Left$(src, 2))
For SrcPos = 3 To Len(src) Step 2
SrcAsc = Val("&H" + Trim(Mid$(src, SrcPos, 2)))
If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1
TmpSrcAsc = SrcAsc Xor Asc(Mid$(key, KeyPos, 1))
If TmpSrcAsc <= offset Then
TmpSrcAsc = 255 + TmpSrcAsc - offset
Else
TmpSrcAsc = TmpSrcAsc - offset
End If
dest = dest + Chr(TmpSrcAsc)
offset = SrcAsc
Next
decrypt = dest
End Function