加解密多媒體檔案 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_20061106153805172.html
procedure FileXor(qFileName : String); //加解密函數
var
fd : array[1..1024] of byte;
hf : integer;
br : Integer;
i : Integer;
begin
hf:=fileopen(qFileName,fmOpenReadWrite);
if hf <> -1 then
begin
FileSeek(hf,0,0);
br :=FileRead(hf, fd, 1024);
for i := 1 to br do
begin
fd[i] := (fd[i]) xor (i mod $ff);
end;
FileSeek(hf,0,0);
filewrite(hf,fd, br);
end;
FileClose(hf);
end;
FORM的CREATE事件裡:
filexor(‘c:\pin.mpg'); //解密MPG檔案
mpp:=cvideo.Create(self); //產生播放MPG控制項
try
mpp.ReadFile(‘c:\pin.mpg',0);
finally
filexor(‘c:\pin.mpg'); //重新加密MPG檔案
end;
mpp.free;
因為MPG檔案正在被使用,所以後來想重新加密MPG檔案不成功。只有在MPP.FREE後面再加密這個檔案才可以。但我在程式中還需要用到這個錄象檔案,不能馬上釋放,如果不馬上把這個檔案加密,程式突然中斷,我的錄象就相當於沒加密了,請問怎麼解決。
一般的錄象加密是怎麼做的,程式中是怎麼解密並啟動並執行,能給個例子嗎
棄置站台 加密好 覆蓋掉原先的.
錄影 本身支援流 播放才能 以 流的方式解壓. 播放.