So, there is my problem. I need to encrypt files (pdf, jpg, zip) and to decrypt it in the initial format. I read Encryption and RandomAccessFile library but it seems like it can only be used for data.
Is there a way to convert file to data and vice versa ?
Or is there another library who can do endrypt/decrypt?
but I have another problem when I want to decrypt the byte array, the app crashes and display that. (My initial file sizes around 11 MB)
B4X:
java.lang.OutOfMemoryError
at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
at java.util.zip.DeflaterOutputStream.finish(DeflaterOutputStream.java:176)
at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:156)
at anywheresoftware.b4a.randomaccessfile.CompressedStreams.CompressBytes(CompressedStreams.java:122)
at b4a.example.main._button2_click(main.java:401)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:63)
at android.view.View.performClick(View.java:4232)
at android.view.View$PerformClick.run(View.java:17298)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Is it possible to allow more memory for the decryption or something like that ?
No, it seems that your file is too big to read into memory in its entirety. You will have to do it incrementally reading from the encrypted file and writing the decrypted data to another file.