B4J Question Encryption works fine in release mode but not in standalone package

AliFarahbod

New Member
Hi,

Encryption works fine in release mode but not in standalone package.
Every thing is well when I run program as a release mode, but not in Standalone package.
I am using Encryption lib in B4A and B4J and not B4XEncryption.

Runnig "run_debug.bat" result like as bellow:


code_module._initializecipher (java line: -1)
java.security.NoSuchAlgorithmException: Cannot find any provider supporting AES/CBC/PKCS7Padding
at java.base/javax.crypto.Cipher.getInstance(Unknown Source)
at b4j/anywheresoftware.b4a.agraham.encryption.CipherWrapper.Initialize(Unknown Source)
at b4j/www.00000.aac_dispatch.code_module._initializecipher(Unknown Source)
at b4j/www.00000.aac_dispatch.code_module._aes_encrypt(Unknown Source)
at b4j/www.00000.aac_dispatch.main$ResumableSub_AppStart.resume(Unknown Source)
at b4j/www.00000.aac_dispatch.main._appstart(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
at b4j/www.00000.aac_dispatch.main.start(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: AES, provider: BC, class: org.bouncycastle.jcajce.provider.symmetric.AES$ECB)
at java.base/java.security.Provider$Service.newInstance(Unknown Source)
... 22 more
Caused by: java.lang.IllegalAccessException: class java.security.Provider (in module java.base) cannot access class org.bouncycastle.jcajce.provider.symmetric.AES$ECB (in module b4j) because module b4j does not export org.bouncycastle.jcajce.provider.symmetric to module java.base
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Unknown Source)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.base/java.security.Provider.newInstanceUtil(Unknown Source)
... 23 more


Any ideas on what I have done wrong ?
 
Last edited:

Erel

Administrator
Staff member
Licensed User
This code works fine after building a standalone package:
B4X:
#AdditionalJar: bcprov-jdk15on-154
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI 
    Private Button1 As B4XView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    Dim x As B4XCipher
    x.Encrypt("test".GetBytes("utf8"), "1234")
End Sub

Try it.
 
Upvote 0
Top