According to your answer for wanting to stream encrypted video in the same way as Netflix, I believe that your need is not possible to do by PHP encryption.
Netflix, iTunes, Amazon Prime Videos, Globo Play, etc are reference services in the use of DRM (Digital Rights Management) to protect their content. After all, the big Hollywood studios don’t want their films to be downloaded and distributed so easily through these new paid video services "on demand".
DRM was a solution found to minimize and protect the illegal download and distribution of media such as audio and video.
Basically, videos that work with DRM are encrypted and need a license to run. The big difference in this case is that, unlike HLS (HTTP Live Streaming) with encryption, the license is sent directly to a CDM (Content Decription Media). CDM is usually installed by default in browsers so that they are able to decrypt DRM protected files.
Today we have 3 major Cdms in the market:
- Widevine, from Google that usually comes installed by default in Google Chrome, Firefox, Opera, etc.
- Play Ready, and is the solution used by Microsoft Edge for example.
- Fair Play, Apple, specifically used by Safari.
The most interesting part of the process is how DRM generates this license, allowing a particular user to watch content. In a simplified way we have:
Each video in MPEG-DASH format has a "manifest file" containing the key that was used to encrypt its fragments. Usually this file has the extension "mpd".
When a video playback request is made, the browser sends the video data plus the user-specific information requesting the license to the server. The DRM server makes a request back to the application server "asking" if the user has permission to specifically view that video. The application server responds YES or NO. If yes, the DRM server releases (Issue) the license that is passed to the browser’s CDM and the video is finally played.
This means that if you download all fragments of MPEG-DASH files, you will not be able to decrypt and even get the "certificate" as it happens in HLS. The only way to get the license is through DRM authentication.
The great disadvantage of DRM, is that it is an expensive solution, mainly because we need at least 3 companies to provide this service: Google, Microsoft and Apple.
Source with more information: https://blog.schoolofnet.com/2017/02/tecnologias-de-video-entenda-como-funcionam-e-qual-delas-implementamos-com-nosso-novo-player/
In this link you will also have more information on how to protect and encrypt these videos:
http://pt.artistscope.com/video_pt.asp
I hope I’ve helped.
As far as I know
file_get_contents
you can take all the data from any file, being text, images or even videos, in string form. After that you can use any encryption algorithm for this data. I never tested with videos, but with picture works normally. Now it’s all about weight. Because a video file transformed into a string and then encrypted will get big as hell, which can even lock your system for a long time. Wouldn’t it be easier for you to compress the ZIP files with password?? What would be your actual usage??– Fernando VR
a type of "Netflix" where the person would be able to download to see, but only on the site, would be used browser cache, and if the person is trying to download the video would come encrypted
– Matheus Lopes Marques
Ahh understood, but I don’t think you could do it with php no. As I said I would overload the server by file size. I’ll put in the answer about how Netflix broadcasts its videos.
– Fernando VR
OK, if you can thank
– Matheus Lopes Marques