Re: how to stream a movie file with fread [success] Now, how to do a fast encrypt ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok, I got it :)


Is there a better way to do a very fast encryption of a file for a key that changes daily ?

The movie is loading and playing at the same time [progressive/rtsp], so the encrypt/decrypt needs to be pretty fast
I tried mcrypt but it seemed way to slow....
Maybe there is a better encryption method ? Or, are there better characters to search/replace ? Does not have to be ultra secure...just needs to be encryption that could last a day or so...as it will change daily.

When I run this, the movie plays, but shows a blank screen and plays no audio...which is exactly what I want :) I want to write a data handler on the user side that connects to a db and gets the $find and $replace keys to unlock the movie

many thanks in advance...and yes, I am experimenting

<?php

$fileSize = filesize($filepath);

header("ETag: ".md5(time()));
header("Accept-Ranges: bytes");
header ("Content-Length: ".$fileSize);
header('Content-Type: video/quicktime');

$find = array("{","ፀ","k","?");
$replace = array("q","m","g","&");

    if( $fd  = fopen($filepath, 'rb')){
     while(!feof($fd)) {
	echo str_replace($find,$replace,  fread($fd, 8192));
     }
     fclose ($fd);
     exit;
   }

?>
On Sep 23, 2005, at 4:07 PM, Graham Anderson wrote:

I am trying to stream a movie file with 'fread'
this my first step in trying to dynamically encrypt the file as it is being streamed from the server

do I need to fread the data in chunks?
If so, how?

$filename ="$path2file";
$file = fopen($filename,'r');
$fileSize = filesize($filename);
$ContentType = " video/quicktime";
header ("Content-type: $ContentType");
header ("Content-length: $fileSize");

while( $filedata_temp = fread($file, $fileSize) )
echo $filedata_temp;

<b>Fatal error</b>: Allowed memory size of 16777216 bytes exhausted (tried to allocate 24113191 bytes) in <b>xxxxxxxx/fopenTest.php</b> on line <b>27</b><br />

BTW, I can get readfile to work just fine :)
AFAIK, readfile does not parameters to alter the file contents

many thanks :)

g

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux