encryptFile(File.DirAssets, "test1.jpg", File.DirLibrary, "crypt_test.jpg")
decryptFile(File.DirLibrary, "crypt_test.jpg", File.DirLibrary, "decrypt_test.jpg")
Sub Process_Globals
#If B4I
Dim Cipher As Cipher
#Else
Dim Cipher As B4XCipher
#End If
Dim su As StringUtils
Dim bc As ByteConverter
Dim Password As String ="blabla"
End Sub
Sub encryptFile(DirSource As String, fileSource As String, DirTarget As String, FileTarget As String)
Dim time As Long =DateTime.Now
Dim in As InputStream
in = File.OpenInput(DirSource, fileSource)
Dim out As OutputStream
out.InitializeToBytesArray(0)
File.Copy2(in, out)
Dim data() As Byte
data = out.ToBytesArray
data=Cipher.Encrypt(data, Password)
Dim Dokumentdatei As RandomAccessFile
Dokumentdatei.Initialize(DirTarget, FileTarget, False)
Dokumentdatei.WriteB4XObject(data, 0)
Dokumentdatei.Close
Log("Verschlüsseln dauert: " & (time-DateTime.Now))
time=DateTime.Now
End Sub
Sub decryptFile(DirSource As String, FileSource As String, DirTarget As String, FileTarget As String)
Dim time As Long =DateTime.Now
Dim data() As Byte
Dim Dokumentdatei As RandomAccessFile
Dokumentdatei.Initialize(DirSource, FileSource, True)
data=Dokumentdatei.ReadB4XObject(0)
Dokumentdatei.Close
data=Cipher.Decrypt(data, Password)
Dim in As InputStream
in.InitializeFromBytesArray(data, 0, data.Length)
Dim out As OutputStream
out=File.OpenOutput(DirTarget, FileTarget, False)
File.Copy2(in, out)
out.Close
Log("Entschlüsseln dauert: " & (time-DateTime.Now))
time=DateTime.Now
End Sub