iOS Question Use of InputStream/OutputStream in a zip and encrypt sub

JackKirk

Well-Known Member
Licensed User
Longtime User
How do I use InputStream and or OutputStream to avoid having to generate the temporary external file tmp.zip - I am quite bamboozled:

B4X:
Private Sub ZipEncrypt(File_Directory As String, File_name As String, Password As String) As Byte

    Private APZ_Serializator As B4XSerializator
    Private APZ_Cipher As Cipher
    Private APZ_Archiver As Archiver
    Private APZ_no As NativeObject

    Private wrk_str As String
    Private wrk_byte() As Byte

    'Zip File_Directory/File_Name to File.DirTemp/tmp.zip
    APZ_no.Initialize("SSZipArchive").RunMethod("createZipFileAtPath:withFilesAtPaths:", _
    Array(File.DirTemp & "/tmp.zip", File_Directory & "/" & File_name)).AsBoolean

    'Read zip back in as string
    wrk_str = File.ReadString(File.DirTemp, "tmp.zip")
   
    'Convert string to bytes then encrypt bytes using password
    wrk_byte = APZ_Cipher.Encrypt(APZ_Serializator.ConvertObjectToBytes(wrk_str), Password)

    Return wrk_byte
   
End Sub

Thanks for any help...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…