Closed AndroidDeveloperLB closed 4 years ago
Never mind, forgot it was special:
Log.d("AppLog", "getting header")
val lazySodiumAndroid = LazySodiumAndroid(SodiumAndroid())
val header = FileInputStream(inputFile).use { UnApkm.processHeader(it, lazySodiumAndroid, true) }
Log.d("AppLog", "done getting header. handling content")
FileInputStream(inputFile).use {
UnApkm.processHeader(it, lazySodiumAndroid, false)
ZipInputStream(UnApkm.decryptStream(it, header, lazySodiumAndroid)).use {
Log.d("AppLog", "got into zip stream")
while (true) {
val name = it.nextEntry?.name ?: break
Log.d("AppLog", "name:$name")
}
}
}
Log.d("AppLog", "done handling content. Handle it again:")
FileInputStream(inputFile).use {
UnApkm.processHeader(it, lazySodiumAndroid, false)
ZipInputStream(UnApkm.decryptStream(it, header, lazySodiumAndroid)).use {
Log.d("AppLog", "got into zip stream2")
while (true) {
val name = it.nextEntry?.name ?: break
Log.d("AppLog", "name:$name")
}
}
}
I remember that I was told here somewhere, that I can re-use the header so that it will be faster.
I've tried to do it, but it failed. Example:
It crashes when it reaches the part of the
val name = it.nextEntry?.name ?: break
as it fails to parse the file as a zip file :Using the normal method, it works fine:
How come? I tried to re-create the instance of
LazySodiumAndroid(SodiumAndroid())
. It didn't work.