terl / hydride-android

Hydride binds against Libhydrogen to provide a simple cryptography that is compatible with Android API 16 and above.
Mozilla Public License 2.0
10 stars 2 forks source link

Native.register() not found in android application. #4

Open vishalkharat opened 4 years ago

vishalkharat commented 4 years ago

We have followed the steps to integrate library into our application. But faced with having crash while initialising Hydrogen

Below is the code we tried with

Native.register(Hydrogen.class, "hydrogen");
Hydrogen hydrogen = new Hydrogen();
hydrogen.hydro_init();

// Make a key
byte[] key = new byte[Hydrogen.HYDRO_SIGN_SECRETKEYBYTES];
hydrogen.hydro_secretbox_keygen(key);

// Make a cipher array to hold the resulting encrypted text
byte[] cipher = new byte[Hydrogen.HYDRO_SECRETBOX_HEADERBYTES + 48];
String context = "context1";
byte[] contextBytes = context.getBytes();
String message = "This is a message that will be encrypted.";
byte[] messageBytes = message.getBytes();
long messageId = 1L;

// Now encrypt
int encryptSuccess = hydrogen.hydro_secretbox_encrypt(cipher, messageBytes, messageBytes.length, messageId, contextBytes, key);

Error: E/zygote64: No implementation found for int co.libly.hydride.Hydrogen.hydro_init()

Can you please let me know how can we get this sorted out?

Gadjerin commented 9 months ago

@vishalkharat You should add this dependency net.java.dev.jna:jna:5.9.0@aar