Encode file to disk:
chave:string; //passphrase
cam:string; //path of file
function CodTabela(i:integer):boolean;
var
motor:TDCP_rc6;
begin
result:=True;
try
mst[i].Position:=0; //memory stream
fst[i]:=TFileStream.Create(cam,fmCreate); //file stream
motor:=TDCP_rc6.Create(nil);
motor.InitStr(chave,TDCP_sha512);
motor.EncryptStream(mst[i],fst[i],mst[i].Size);
motor.Burn;
motor.Free;
fst[i].Free;
mst[i].Free;
except
result:=False;
end;
end;
Decod file to memory:
function DecodTabela(i:integer):boolean;
var
motor:TDCP_rc6;
begin
result:=True;
try
mst[i]:=TMemoryStream.Create;
fst[i]:=TFileStream.Create(cam,fmOpenRead);
motor:=TDCP_rc6.Create(nil);
motor.InitStr(chave,TDCP_sha512);
motor.DecryptStream(fst[i],mst[i],fst[i].Size);
motor.Burn;
motor.Free;
fst[i].Free;
except
result:=False;
end;
end;