B4J Tutorial Share encrypted data with B4A

For new projects it is recommended to use B4XEncryption to create a cross platform solution.

RandomAccessFile library v1.10 includes the beloved ReadEncrypredObject / WriteEncryptedObject methods.

These two methods are similar to ReadObject and WriteObject methods which are very powerful and useful and they allow you to easily write complex objects in a single line of code.

ReadEncryptedObject and WriteEncryptedObject methods also encrypt the data. The B4A tutorial is available here: Encrypting information with RandomAccessFile library

The encryption method used is the same in B4J and B4A so you can easily exchange secured data between your mobile app and desktop app.

The algorithm name is: PBEWITHSHAAND256BITAES-CBC-BC

Note that you can also write custom types and collections of custom types. The saved types can also be shared between B4J and B4A.

These two methods depend on an encryption library named Bouncy Castle. Android includes this library as part of the OS.
In B4J you need to download the jar file: https://www.bouncycastle.org/download/bcprov-jdk15on-154.jar and copy it to the additional libraries folder.

In your code you should add the following module attribute:
#AdditionalJar: bcprov-jdk15on-154
 
Last edited:

rboeck

Well-Known Member
Licensed User
Longtime User
I tried to use encryption for the first time with B4J and i am getting:

error reading C:\Program Files\Anywhere Software\B4J\libraries\bcprov-jdk15on-150.jar; error in opening zip file
1 error

I am using jdk 1.8.0_31; do have to go back to jdk 1.7 ?
 
Top