Android Question [SOLVED] but Strange error using Agraham Encryption lib Ver. 1.10

Lello1964

Well-Known Member
Licensed User
Longtime User
I have a strange error using agraham Encryption lib Ver. 1.10
i read CryptedString from USB using Astreams

this is a crypted string,
i call AesEncrypt sub to decrypt
if i see tmpByte () content in Debug, it's right,
but when i try to convert tmpByte to hex i have the error
java.lang.NullPointerException: expected receiver of type anywheresoftware.b4a.agraham.byteconverter.ByteConverter, but got null


Main.DeCryptedString string contain right string from byte, but if i try to use it i have some error

if i try to replicate problem with smaller new program using fixed string, the program go ok.

this is part of code and log

B4X:
Log(CryptedString)
Dim tmpByte()  As Byte
Dim newString As String
tmpByte=funzioni.AesEncrypt(CryptedString,Main.EnryptPassword,1)
newString =bc.HexFromBytes(tmpByte)

Sub AesEncrypt(Text As String ,chiave  As String,  Mode As Int) As Byte()  'mode= 0/1 = encode/decode
    Dim key()  As Byte
    Dim data() As Byte
    Dim bytes() As Byte

    key = ByteConv.HexToBytes(chiave)
    Dim Kg As KeyGenerator
    Dim c As Cipher
    c.Initialize("AES/ECB/NoPadding") ' just "DES" actually performs "DES/ECB/PKCS5Padding".
    Kg.Initialize("AES")

    Kg.KeyFromBytes(key)
    If Mode = 0 Then
        data =ByteConv.HexToBytes(Text)
        data = c.Encrypt(data, Kg.key, False)
          Return  data
    Else If Mode = 1 Then
        data = ByteConv.HexToBytes(Text)
        bytes = c.Decrypt(data, Kg.key,False)
        Main.DeCryptedString=ByteConv.HexFromBytes(bytes)
        Return bytes
    End If
End Sub

This is Log :

0101000000F0F111C801E96BDAD84986
Error occurred on line: 283 (ConnectOpper)
java.lang.NullPointerException: expected receiver of type anywheresoftware.b4a.agraham.byteconverter.ByteConverter, but got null
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:265)
at b4a.example1.connectopper._rispostaopper(connectopper.java:574)
at b4a.example1.usbserialopper._astreams2_newdata(usbserialopper.java:306)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:479)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:293)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
 
Last edited:

Lello1964

Well-Known Member
Licensed User
Longtime User
[SOLVED]
I have solved ,

I hav't declared :
Dim bc As ByteConverter
in Process_Globals but in a Sub of code.
and this generate error during run

But i think is a BUG.
 
Last edited:
Upvote 0
Top