ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to encrypt whole image while saving
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
727 Posts

Posted - Mar 25 2014 :  21:16:15  Show Profile  Reply
Hello,

I have to need to save ImageEn contents will all its layers intact to file.

Currently I am encrypting each layers using the encryption feature of ImageEn and then saving to file but this is taking very long at times especially when there are very large numbers of layes loaded with many large images.

In the same way it take a long time to load a file with multiple layers as we have to first load the file and then decrypt each layer.

I was wondering if there is a way to encrypt the contents at the time of saving to file. I think this will speed up the process.

Can someone help me here please?

TIA




Yogi Yang

xequte

38608 Posts

Posted - Mar 27 2014 :  01:38:10  Show Profile  Reply
Hi Yogi

You would probably be better to save to a stream, encrypt the stream using a third party library (e.g. Lockbox) and save it to file.






Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

yogiyang

India
727 Posts

Posted - Mar 30 2014 :  21:31:52  Show Profile  Reply
Thanks for the suggestion. I will look into this component.

Regards,




Yogi Yang
Go to Top of Page

yogiyang

India
727 Posts

Posted - Apr 01 2014 :  08:14:36  Show Profile  Reply
Hello Nigel,

I tried as per your suggestions and managed to save file properly but now I am not able to reload the file in ImageEN.

I have placed two components on Form - CryptographicLibrary1 and Codec1. I conneced both by setting Codec1's CryptoLibrary property to CryptographicLibrary1.

Here is the code to save file that seems to work:

var
fsPlain: TMemoryStream;
fsChiper: TFileStream;

...

Codec1.Reset;
Codec1.Password := '5961414C4C4148';

fsPlain := TMemoryStream.Create();
fsChiper := TFileStream.Create(SaveDialog1.FileName, fmCreate);

Child.ImageEnView1.LayersSaveToStream(fsPlain, -1);

Codec1.EncryptStream(fsPlain, fsChiper);

fsChiper.Free;
fsPlain.Free;


While the code to Load file is:

var
fsPlain: TMemoryStream;
fsChiper: TFileStream;

...

Codec1.Reset;
Codec1.Password := '5961414C4C4148';

fsPlain := TMemoryStream.Create();
fsChiper := TFileStream.Create(Name, fmOpenRead);

Codec1.DecryptStream(fsPlain, fsChiper);

Child.ImageEnView1.LayersLoadFromStream(fsPlain);

fsChiper.Free;
fsPlain.Free;


Please guide me here.

TIA

Yogi Yang


Yogi Yang
Go to Top of Page

xequte

38608 Posts

Posted - Apr 01 2014 :  13:27:51  Show Profile  Reply
Hi Yogi

I haven't used Lockbox for a long time, so you may be better off on the Stack Overflow forum for Lockbox queries.

I can't see anything specifically wrong with your code, except that you probably need to reset the position of the streams before each method call.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

yogiyang

India
727 Posts

Posted - Apr 01 2014 :  21:18:36  Show Profile  Reply
quote:
I haven't used Lockbox for a long time, so you may be better off on the Stack Overflow forum for Lockbox queries.

Even though you have not used LockBox you solution worked! I spent one whole day trying to get the encrypted file back in ImageEN but without success.

It never occured to me that I should reset Stream Position to 0.

Thanks for this productive tip. :)

This solved my problem in a snap!



Yogi Yang
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: