I found some tutorials online that could help but I am not sure there the best options. I would like to encrypt the file with a highly secure algorithm (I am a bit paranoid) but at the same time I am looking for speed (I know it's a bit of a contradiction)... So I chose AES-256... But what is the best way to use AES-256 with PHP to encrypt files?
The AES-256 key schedule transforms a 256-bit secret key into fourteen 128-bit rounds keys. Of the two, the AES-128 key schedule is actually more secure. The AES-256 key schedule has known weaknesses that might make it possible to perform related key attacks against the algorithm.
End-to-end encryption works in two different ways: symmetric or asymmetric. Symmetric encryption encodes data and offers the greatest possible security through AES-256 encryption. However, this also requires the AES-256 key itself to be transmitted securely and confidentially.
For a symmetric algorithm, use Mcrypt.
Note though that it can be risky, from a security perspective, to use that library without knowing what everything does. Take a look at some ready-made solutions.
(Incidentally, the ciphers supported are here).
The Mcrypt extension was deprecated in 7.1 and removed in 7.2, so you will need an alternative. Use Sodium instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With