1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4J Tutorial Share encrypted data with B4A

Discussion in 'B4J Tutorials' started by Erel, Dec 9, 2013.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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


    RandomAccessFile v1.10 is attached.
     

    Attached Files:

    Last edited: Aug 16, 2016
    pesquera, lemonisdead and flashiranfa like this.
  2. rboeck

    rboeck Well-Known Member Licensed 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 ?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    It is not related to the Java version.

    My guess is that the file was copied to the virtualized program files folder. Delete the jar from the internal libraries folder and copy it to the additional libraries folder (which shouldn't be inside program files).
     
  4. rboeck

    rboeck Well-Known Member Licensed User

    I tried another path outside of program files, but it did not change anything. So i tried 'bcprov-jdk15on-151' from http://www.bouncycastle.org/latest_releases.html and it worked; what the problem with the older version was, is still unclear for me.

    Thanks for your help!
     
  5. walt61

    walt61 Active Member Licensed User

    wonder likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice