Hi,
I made some tests with encryption using code found here on the forum and Agraham's ByteConverter & Encryption libraries. I had a look at the Encryption library and it seems it does not use any specific android imports so I thought it should work with B4J.
The attached zip-file "b4jworks.zip" works fine using same code both in B4A and B4J.
The code in "b4atest.zip" and "b4jtest2.zip" uses "InitialisationVector" and it works fine in B4A but not in B4J. In B4J I get an error "java.security.InvalidKeyException: Invalid key length: 16 bytes" as follows:
Am I doing something wrong (maybe with the key) or could certain things of the Cipher-object be not compatible with B4J?
I made some tests with encryption using code found here on the forum and Agraham's ByteConverter & Encryption libraries. I had a look at the Encryption library and it seems it does not use any specific android imports so I thought it should work with B4J.
The attached zip-file "b4jworks.zip" works fine using same code both in B4A and B4J.
The code in "b4atest.zip" and "b4jtest2.zip" uses "InitialisationVector" and it works fine in B4A but not in B4J. In B4J I get an error "java.security.InvalidKeyException: Invalid key length: 16 bytes" as follows:
B4X:
Program started.
text to encrypt: This is a test
Error occurred on line: 43 (main)
java.security.InvalidKeyException: Invalid key length: 16 bytes
at com.sun.crypto.provider.DESedeCipher.engineGetKeySize(DESedeCipher.java:370)
at javax.crypto.Cipher.passCryptoPermCheck(Cipher.java:1052)
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1023)
at javax.crypto.Cipher.implInit(Cipher.java:790)
at javax.crypto.Cipher.chooseProvider(Cipher.java:849)
at javax.crypto.Cipher.init(Cipher.java:1348)
at javax.crypto.Cipher.init(Cipher.java:1282)
at anywheresoftware.b4a.agraham.encryption.CipherWrapper.doFinal(CipherWrapper.java:136)
at anywheresoftware.b4a.agraham.encryption.CipherWrapper.Encrypt(CipherWrapper.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:468)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:209)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:153)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:86)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:69)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:32)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:216)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:744)
Am I doing something wrong (maybe with the key) or could certain things of the Cipher-object be not compatible with B4J?
Attachments
Last edited: