Hi, because I need to share data with another application, I'm trying to decode data in AES.
From another application I encryped this string:
Now, I can to decrypt this with another application, but not with B4A.
With B4A I receive this error:
The code used to decrypt is:
Where am I doing wrong?
Thanks.
From another application I encryped this string:
with password:Hello from Stefano that trying to encrypt in AES
and the result is:12345678901234567890123456789012
B4X:
0x74, 0x02, 0x35, 0x19, 0x2E, 0x0E, 0x40, 0x41, 0x27, 0x2F, 0xC4, 0x00,
0xF7, 0xC1, 0x76, 0x9D, 0xE6, 0xC6, 0x76, 0xBA, 0x10, 0xC1, 0x4C, 0xF0,
0xC1, 0x81, 0x98, 0x40, 0x7B, 0x09, 0x3D, 0x1D, 0xE9, 0xD5, 0x53, 0x9F,
0xD4, 0x16, 0xF6, 0x20, 0xDA, 0xEB, 0xC7, 0x9D, 0xE4, 0x5F, 0x7E, 0x74
Now, I can to decrypt this with another application, but not with B4A.
With B4A I receive this error:
B4X:
Error occurred on line: 453 (BT_Service)
javax.crypto.IllegalBlockSizeException: error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH
at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
at com.android.org.conscrypt.OpenSSLCipher$EVP_CIPHER.doFinalInternal(OpenSSLCipher.java:570)
at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:351)
at javax.crypto.Cipher.doFinal(Cipher.java:1736)
at anywheresoftware.b4a.object.B4XEncryption.Decrypt(B4XEncryption.java:47)
at java.lang.reflect.Method.invoke(Native Method)
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 java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6291)
at android.view.View$PerformClick.run(View.java:24931)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
The code used to decrypt is:
B4X:
Dim e() As Byte = Array As Byte(0x74, 0x02, 0x35, 0x19, 0x2E, 0x0E, 0x40, 0x41, 0x27, 0x2F, 0xC4, 0x00, _
0xF7, 0xC1, 0x76, 0x9D, 0xE6, 0xC6, 0x76, 0xBA, 0x10, 0xC1, 0x4C, 0xF0, _
0xC1, 0x81, 0x98, 0x40, 0x7B, 0x09, 0x3D, 0x1D, 0xE9, 0xD5, 0x53, 0x9F, _
0xD4, 0x16, 0xF6, 0x20, 0xDA, 0xEB, 0xC7, 0x9D, 0xE4, 0x5F, 0x7E, 0x74)
Dim Cipher As B4XCipher
Dim Decrypted() As Byte
Decrypted=Cipher.Decrypt(e, "12345678901234567890123456789012")
Where am I doing wrong?
Thanks.
Last edited: