There was a task to set up encryption in the links of paths to media files for placing movies on the site.
We use nginx for this:
rewrite /([a-zA-Z0-9_\-]+)/([0-9]+)/(.+)\.mp4$ /$3.mp4?md5=$1&time=$2;
location / {
secure_link $arg_md5,$arg_time;
secure_link_md5 SECRET_