10-24-2017 10:37 AM - edited 10-24-2017 10:57 AM
@Pepe727 wrote:
Hey! I would like to read any type of file and read them as binary (Obtain an 1d array of U8 or an 2d array 8bits x sizearray) and when I have manipulated it, rebuild the original file.
A file is just a generic linear stream of bytes. What you do with it is up to you. You can read it raw, process it, and write it back raw using the tools already mentioned by others.
There is only one dimension: Each element has exactly one index (its position in the file!) so your question about a 2D array requires clarification. Of course you can think of the bits in a byte as a second dimension, but that does not make it a 2D array unless you inflate it to some much more inefficient 2D boolean array for example where each elements corresponds to a bit. This will take 8x more memory and will slow you down and is not needed.
All boolean operations will work on integers directly and will do bitwise operations if applied. That's all you need for e.g. encryption or other processing. The code should be mostly blue. No need for green datatypes.
Here's one possibility:
To ensure correct operations, you need to be careful.