1. Encrypting image files

Can anyone recommend any of the libraries for encrypting image files jpg etc.

I would like to decrypt it to memory rather than to a temp file.

At the moment I am loading image files with cximage so I'm not sure how I would decrypt an image and display it.

new topic     » topic index » view message » categorize

2. Re: Encrypting image files

I think I suggested before, use Blowfish. It allows you to encrypt/decrypt sequences in memory. I used it for a password manager that saves encrypted passwords to a Euphoria database. I would imagine it'd be the same, except for the data. I could provide an example, if you need...

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: Encrypting image files

At the moment the image is loaded into an Atom (see below)

I don't really know how I would take a jpg image and encrypt it, then decrypt it and load using the ataom as a handle.

So yes if you could knock up an example I would appreciate it.

Snip from my program

 -- Load an image from file 
 image = CXI_LoadImage("MyImage.jpg", CXI_FORMAT_UNKNOWN, 0) 
 ImageResize() 
 clearWindow(myPixMap) 
 DestX = 0 
 DestY = 0 
 ImageZoomed=False 
 bitBlt(myPixMap,5,5,createDIBFromCXImage(image),0,0,BitmapSize[1],BitmapSize[2],SRCCOPY) 
 
new topic     » goto parent     » topic index » view message » categorize

4. Re: Encrypting image files

Since CXI_LoadImage can load the image from memory you could read the encrypted file from disk, decrypt it, poke it to memory and pass the address of the decrypted data to CXI_LoadImage.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Encrypting image files

mic_ said...

Since CXI_LoadImage can load the image from memory you could read the encrypted file from disk, decrypt it, poke it to memory and pass the address of the decrypted data to CXI_LoadImage.

WAY over my head. I understand what your saying but would not have a clue on how to achieve this.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Encrypting image files

Hi

Remember, the atom is just a pointer to an area of memory where the bitmap is held. You need to manipulate that area of memory, basically you need to know its size (can't remember without playing how to do this), then reference from that pointer (the atom). Starting to get a bit C ish - sorry. But theoretically, you could allocate another area of memory, copy and encrypt / decrypt to and from those two areas of memory.

Chris

new topic     » goto parent     » topic index » view message » categorize

7. Re: Encrypting image files

If this is at all possible with EU then I need someone to give me a sample. It is not within my capability :(

Anyone have some spare time to help?

new topic     » goto parent     » topic index » view message » categorize

8. Re: Encrypting image files

lockiedownunder said...

If this is at all possible with EU then I need someone to give me a sample. It is not within my capability :(

Anyone have some spare time to help?

Not really, but if I understand, you have some .jpg files which you want to distribute with your program, so that a user clicking within your program will see the pics, but you don't want to distribute the pics "in the clear".

If that's right, then the "blowfish" previously mentioned sounds like it can do what you want, as follows:

1. write a small program to read in all your .jpg files, one at a time, in binary format, and immediately write them back out with some other extent, like "*.pic", or something, BUT PUT THE BLOWFISH PROCEDURE, "Set_Encrypt()" in your code BEFORE YOU OPEN THE FILES TO WRITE (or before EACH file, I'm not sure, haven't used it)

that will give you a set of files to distribute that are encrypted.

2. continue writing your main program, and put the Blowfish procedure Set_Encrypt() with the parameter "ENC_AUTO", which should automatically decrypt any file which you ask to be read in.

3. then proceed with the decrypted pics however you wish.

I'm not sure how the app user applies a password, but I suspect the Blowfish doc tells how somewhere.

HTH? dan

new topic     » goto parent     » topic index » view message » categorize

9. Re: Encrypting image files

Blowfish library does not work

I am trying to use the Blowfish library but get this error

D:\EUPHORIA\Include\database.e:133 A namespace qualifier is needed to resolve allocate. allocate is defined as a global symbol in: D:\EUPHORIA\Include\machine.e D:\Tony\D Documents\My Programing\SafesDB2\blowfish.e

mem0 = allocate(4)

new topic     » goto parent     » topic index » view message » categorize

10. Re: Encrypting image files

The blowfish library was probably written before namespaces were added to Euphoria. If both files contain global symbols with the same name you need to help the interpreter tell them apart somehow. Namespaces are documented in the Eu 4 documentation: http://rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=documentation

new topic     » goto parent     » topic index » view message » categorize

11. Re: Encrypting image files

lockiedownunder said...

Blowfish library does not work

I am trying to use the Blowfish library but get this error

D:\EUPHORIA\Include\database.e:133 A namespace qualifier is needed to resolve allocate. allocate is defined as a global symbol in: D:\EUPHORIA\Include\machine.e D:\Tony\D Documents\My Programing\SafesDB2\blowfish.e

mem0 = allocate(4)

I see Mic's observation that "The blowfish library was probably written before namespaces were added to Euphoria.", and I see in Eu 3.1 doc that while a namespace conflict could be fixed by changing the duplicate name in one of the conflicting librarys, and since the blowfish.e "allocate" is almost certainly not used outside the library, one could just make the blowfish allocate not global.

But if I wanted to use the namespace identification scheme instead, so as to make the blowfish.e allocate never be seen in a program that includes blowfish.e, would that mean that I'd have to tack the blowfish namespace id onto every blowfish function that would be used in my app?

Dan (who's not "lockiedownunder", but may also need to use encryption)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu