I am a programmer familiar with C/C++ and Python. Lately, we got an assignment from a team asking us to work on one of their projects: we need to make a small program to encrypt a large file using symmetric key encryption. We could easily achieve this using AES128 or AES256 in CRT mode.
The catch however is that if a small part of the file is given along with the location of that bytes from the beginning of the file we should be able to decrypt just that piece.
We thought cutting the file into multiple pieces and applying separate generated key for each but the issue is that regarding what we can do if the said part is not exactly a slice of the size we cut it into. Also would like to know if two over lapping such blocks can be handle.
The idea we are currently working on is this:
- We are slicing into 128 bytes each.
- Calculate number of bytes from the last slice. So if we get bytes from 10 to 128. It will be 9.
- Generate a random padding of 9 bytes at the beginning and then decrypt it. Then remove the first 9 Bytes.
- In case multiple slices overlap they are split and the method is repeated.
So, what I would like to know is if this is sensible or if there's a better cipher or algorithm that allows this.
- The files will be image files or document files.
- Only know some basics of cryptography.