B4J Question Faster Encryption Library (tested - it is not faster)... found one but how I will make it work ?

Magma

Expert
Licensed User
Longtime User
Hi there...
well I am searching various things to make my work faster... B4XEncryption is very fast... but this says it is faster (edit: IT IS NOT !!!)... and I want to test it...


I wanna try it... but somewhere loosing something... (as always) - any help appreciated!

What i ve done:
B4X:
    #AdditionalJar: crypto-core-1.1.0.jar

B4X:
    Private joMe As JavaObject
    Dim startTime, stopTime As Long

    joMe=Me
   
    startTime = DateTime.Now
    Dim bb2() As Byte=joMe.RunMethod("cencrypt",Array("testpass",bb))  ''bb could be bytes from image or something else
    stopTime = DateTime.Now
    Log(bb2.Length)
    Log("encrypt time " & (stopTime-startTime) & "ms")

...

#if Java


import crypto.AES;
import crypto.Key;
import crypto.Util;


   public static byte[] cencrypt(String ppass, byte[] ssomedata) throws Exception {
   try {
   Key.ExpandedKey key = Key.KeySize.AES_128.genKeysHmacSha(ppass.getBytes());
   byte[] encryptedData = crypto.AES.encryptCBC(key, ssomedata);
    return encryptedData;
   } catch (Exception e) {
    e.printStackTrace();
    return null;
      }
   }
  
   public static byte[] cdecrypt(String ppass, byte[] ssomedata) throws Exception {
   try {
   Key.ExpandedKey key = Key.KeySize.AES_128.genKeysHmacSha(ppass.getBytes());
   byte[] decryptedData = crypto.AES.decryptGCM(key, ssomedata);
    return decryptedData;
   } catch (Exception e) {
    e.printStackTrace();
    return null;
      }
   }

#End If


getting this error:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.main$ResumableSub_Turtle_Start.resume(main.java:548)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1051)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NoClassDefFoundError: at/favre/lib/crypto/HKDF
at crypto.Key$KeySize.genKeysHmacSha(Key.java:76)
at b4j.example.main.cencrypt(main.java:1547)
... 28 more
Caused by: java.lang.ClassNotFoundException: at.favre.lib.crypto.HKDF
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 30 more
 
Last edited:
Solution
Top