Hi there.. once again,
so.. i am facing a little issue again (as usual). Since i am relatively new to B4A on file manipulation i have now faced a problem that some of you have as well. I am trying to obfuscate some of my assets files by intentionally remove a few bytes from the header and on user demand i want to add those missing values again and by this way restore the original binary for usage.
So far i have came with this code :
In order to remove a few random bytes from the reading that i might not want there i just need to replace the code as follows :
by
But.. how do i add a few bytes in the start of the array?
I was trying to do this :
.. in order to add "%PDF-1.5" bytes to the start of the buffer (data) as if a string manipulation but i don't really know how to combine two arrays of bytes at the start of one specific array. I know that the code can't possibly work as is.. i mean with the "&" operator (as if a string manipulation)... but is there any homologue function for arrays of bytes or a specific library function?
Any suggestion or tip?
so.. i am facing a little issue again (as usual). Since i am relatively new to B4A on file manipulation i have now faced a problem that some of you have as well. I am trying to obfuscate some of my assets files by intentionally remove a few bytes from the header and on user demand i want to add those missing values again and by this way restore the original binary for usage.
So far i have came with this code :
B4X:
Sub decode_file(path_to_save As String, Original_file As String, Saved_file As String)
Dim In As InputStream '<--------- from file to array of byte
In = File.OpenInput(File.DirAssets, Original_file)
Dim out As OutputStream
out.InitializeToBytesArray(1000)
File.Copy2(In, out) '<---- This does the copying
Dim data() As Byte
'-------------------------------*****START OF ADD MISSING BYTES*******--------------------------
data = "%PDF-1.5".GetBytes("UTF8") '<---- as it seems this can't be done
data = data & out.ToBytesArray '<---- as it seems this can't be done
'-------------------------------*****END OF ADDING MISSING BYTES*******--------------------------
out.Flush '<---- Flushing of the buffer in order to be used again
'--------- Now it is being converted from array of byte to file again
out = File.OpenOutput(path_to_save, Saved_file, False)
out.WriteBytes(data, 0, data.Length)
out.Close
In.Close
End Sub
In order to remove a few random bytes from the reading that i might not want there i just need to replace the code as follows :
B4X:
out.WriteBytes(data, 0, data.Length)
by
B4X:
out.WriteBytes(data, Start_index, data.Length-Ending-Index)
But.. how do i add a few bytes in the start of the array?
I was trying to do this :
B4X:
'-------------------------------************--------------------------
data = "%PDF-1.5".GetBytes("UTF8") '<---- as it seems this can't be done
data = data & out.ToBytesArray '<---- as it seems this can't be done
'-------------------------------************--------------------------
.. in order to add "%PDF-1.5" bytes to the start of the buffer (data) as if a string manipulation but i don't really know how to combine two arrays of bytes at the start of one specific array. I know that the code can't possibly work as is.. i mean with the "&" operator (as if a string manipulation)... but is there any homologue function for arrays of bytes or a specific library function?
Any suggestion or tip?
Last edited: