I thought encryption algorithms (like AES) are used to encrypt texts. So, how are files or folders (containing pictures, videos, etc.) encrypted? What is it that encryption algorithms exactly encrypt?
All files (text, video, whatever) consist of bits. The general procedure with symmetric encryption algorithms (such as AES) is they generate a stream of pseudo random bits, which is derived from a key or password, and then they mangle (typically XOR) the original data with the random data. Thus resulting in new data that appears to be totally random.
Without the key or password, there is no way to predict or generate the peuso random data, so it's also impossible to distinguish the original bits from the encrypted result.
Decrypting works the same way: when you enter the valid key, the same pseudo random mangle data is generated, so it can undo the mangling (e.g. XOR again) and restore the original data.
It makes no difference whatsoever whether you encrypt text, or pictures, or video, or data that might even be already encrypted otherwise. Data is just data: a fancy collection of ones and zeroes.
Others have already given the answer, so the following just uses slightly different words that might be helpful.
Files on a computer consists of bytes. Bytes are made up of bits. A bit is a
0 or a
1. A byte consists of 8 bits. That is, a byte is a string of 8
0's (a binary string). Most encryption algorithms works of the bits. So if you have a file, then the algorithm treats the file as a binary string.
If you want to find the string of bits or bytes making up a file you can use a Hex editor. If you are on Windows I can recommend XVI32. You simply open the file with the program and see the bytes. Now since you are using a Hex editor, the bytes will be written as two hexadecimal digits. For example, the byte
E2 corresponds to the dcimal value
226. As a binary string this is
11100010. There are a bunch of applications online that will give you this conversion and there are many good explanations of how this works.
Now AES is a 128 bit block cipher. That means it encrypts the file is 128 bis blocks. 128 bits is 16 bytes (128/8 = 16). So you take chucks of 16 bytes and encrypts them. There is a lot more to how exactly this is done. There are, for example, different modes of operation.