I am trying to hash a string variable with the ByteConverter and Encryption libraries and return the hashed value as a string. I found some clues on this thread: http://www.b4x.com/forum/libraries-developers-questions/10273-hex-string.html#post57117.
With this background, I tried code like this:
However, when I try this code, I get a compiling error: Cannot cast type: {Type=String, Rank=0} to: {Type=Byte,Rank=1} Occurred on line: hasheddata=Bconv.StringFromBytes(hasheddata,"UTF8").
What am I doing wrong?
Thank you for any advice!
With this background, I tried code like this:
B4X:
Dim Bconv As ByteConverter
Dim datatohash As String
Dim hasheddata(0) As Byte
Dim md As MessageDigest
datatohash="abcdefg"
hasheddata = Bconv.StringToBytes(datatohash, "UTF8")
hasheddata = md.GetMessageDigest(hasheddata, "SHA-512")
hasheddata=Bconv.StringFromBytes(hasheddata,"UTF8")
However, when I try this code, I get a compiling error: Cannot cast type: {Type=String, Rank=0} to: {Type=Byte,Rank=1} Occurred on line: hasheddata=Bconv.StringFromBytes(hasheddata,"UTF8").
What am I doing wrong?
Thank you for any advice!