B4J Question Where can I find the Encryption library?

MathiasM

Member
Licensed User
Ok, in that case I'm doing something wrong..
I have this code for testing:

B4X:
   Dim testString As String = "test"
   Dim crypto As MessageDigest
   Log(crypto.GetMessageDigest(testString.GetBytes("UTF8"), "SHA-512"))
Error:

B4J line: 36
Log(crypto.GetMessageDigest(testString.GetBytes(\
javac 1.8.0_202
src\b4j\example\main.java:128: error: no suitable method found for NumberToString(byte[])
anywheresoftware.b4a.keywords.Common.Log(BA.NumberToString(_crypto.GetMessageDigest(_teststring.getBytes("UTF8"),"SHA-512")));
^
method BA.NumberToString(double) is not applicable
(argument mismatch; byte[] cannot be converted to double)
method BA.NumberToString(float) is not applicable
(argument mismatch; byte[] cannot be converted to float)
method BA.NumberToString(int) is not applicable
(argument mismatch; byte[] cannot be converted to int)
method BA.NumberToString(long) is not applicable
(argument mismatch; byte[] cannot be converted to long)
method BA.NumberToString(Number) is not applicable
(argument mismatch; byte[] cannot be converted to Number)
1 error
Any idea?
 

Erel

Administrator
Staff member
Licensed User
You cannot log arrays of bytes. GetMessageDigest returns an array of bytes.

If you want to log it:
B4X:
Dim bc As ByteConverter
Log(bc.HexFromBytes(crypto.GetMessageDigest(...)))
 
Top