Stream support ? - WeOnlyDo Discussion board

Stream support ? (wodCrypt)

by dandraka, Monday, November 07, 2005, 17:36 (4400 days ago)

Hi,

We are using wodCrypt for an application of ours, and we have the following problem:

It seems that, in order to decrypt a file the component needs to load it all in memory first. And while the encryption/decryption is done correctly, this causes huge delays: a typical file is about 20-30MB, and a typical user has about 128-256 of memory. So loading all 30MB in memory causes extensive disk swapping.

Is there a way to implement your component withing a FileStream ?

Below is a code snippet, example of how we use wodCrypt (Delphi 7):

Function DecryptFile(Const Source,Destination: String): Integer;
Const
SKey = 'myProgKey';
LKey = 'myLicense';
Var
CryptObject: TWodCryptCom;
SourceBlob, DestinationBlob : TWodMemBlob;
SBlob, DBlob : IBlob;
Begin
Try
Try
CoInitialize(nil);
SourceBlob := WODCRYPTCOMLib_TLB.TwodMemBlob.Create(nil);
DestinationBlob := WODCRYPTCOMLib_TLB.TwodMemBlob.Create(nil);
SourceBlob.FromFile(Source);
SourceBlob.DefaultInterface.QueryInterface(WODCRYPTCOMLib_TLB.IID_IBlob, SBlob);
DestinationBlob.DefaultInterface.QueryInterface(WODCRYPTCOMLib_TLB.IID_IBlob, DBlob);
CryptObject := TwodCryptCom.Create(nil);
With CryptObject Do Begin
LicenseKey := LKey;
Optimized := False;
type_ := Blowfish;
SecretKey := SKey;
Decrypt(SBlob, DBlob);
End;
DestinationBlob.ToFile(Destination);
Finally
FreeAndNil(DestinationBlob);
FreeAndNil(SourceBlob);
FreeAndNil(CryptObject);
End;
Result := NO_ERROR;
Except
Result := ERROR;
End;
End;


Complete thread: