[Bug] Can't decodebase64

NeoTechni

Well-Known Member
Licensed User
Longtime User
B4X:
Compiling code.                         0.09
Generating R file.                      0.00
Compiling generated Java code.          Error
B4A line: 24
Pattern= su.DecodeBase64(   Pattern  )
javac 1.6.0_24
src\omnicorp\playstationcollector\main.java:1486: cannot find symbol
symbol  : method NumberToString(byte[])
location: class anywheresoftware.b4a.BA
_pattern = BA.NumberToString(_su.DecodeBase64(_pattern));
             ^
1 error

I'm trying to decode a base64encoded string, to a string.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
it is. I've also tried

B4X:
dim Bytes() As Byte , Pattern As String 
Pattern= Settings.GetDefault("UserID",  "-1"  )
Bytes= su.DecodeBase64(    Pattern   ) 
      pattern= bytes

Compiling code. 0.08
Generating R file. 0.00
Compiling generated Java code. Error
B4A line: 25
pattern= bytes
javac 1.6.0_24
src\omnicorp\playstationcollector\main.java:1491: cannot find symbol
symbol : method NumberToString(byte[])
location: class anywheresoftware.b4a.BA
_pattern = BA.NumberToString(_bytes);
^
1 error

I've tried decoding the encoded string in another program to be sure, and I do get the correct value I encoded.
 
Last edited:

NeoTechni

Well-Known Member
Licensed User
Longtime User
Dah, you're kidding me. You keep making it so simple. And I just got it working with the ByteConverter library
 

Dario126

Member
Licensed User
Longtime User
I get this error
java.lang.StringIndexOutOfBoundsException: length=22; regionStart=0; regionLength=32

when running following code
B4X:
Dim SU As StringUtils = "gaCpU6ikVpymnKOro6hkmpybq6qipw=="
Dim sData1 As String
Dim bData() As Byte
bData = SU.DecodeBase64(sData)
sData1 = BytesToString(bData, 0, sData.Length, "UTF-8")

Log("DecodedData: " & sData1)

Error is in BytesToString line..
Why?

Is CharSet wrong?
SU source string is coded by PHP base64_encode function.
 
Last edited:

Dario126

Member
Licensed User
Longtime User
I had error by using "sData.Length" which was string, not byte array .. :oops:

And now works with "UTF8" and "UTF-8" also. Btw. "UTF-8" is referenced as example in popup help in code editor.

But I have some differences when decoded this with B4A or with PHP. But I'll move this topic to new thread ..

Tnx ..
 
Top