iOS Question Convert hex byte to string

omidaghakhani1368

Well-Known Member
Licensed User
Hi.
I use below code to convert md5 result to string.
In basic4android with byteconvertor library we can convert hex byte to string but in b4i?
B4X:
dim s as string
s = "hello"
b1 = c1.GetMessageDigest(s.GetBytes("UTF8"),"MD5")
s = BytesToString(b1,0,b1.Length,"UTF-8")
Above code error to decoding b1
 

Erel

Administrator
Staff member
Licensed User
This code is incorrect in both B4A and B4i.

You cannot treat raw bytes as string. If you like to convert raw bytes to hex string then you should use ByteConverter. In B4i it is part of RandomAccessFile library.
 
Top