1. Encrypting image files
- Posted by lockiedownunder Jun 29, 2009
- 979 views
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.
2. Re: Encrypting image files
- Posted by ghaberek (admin) Jun 29, 2009
- 1008 views
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
3. Re: Encrypting image files
- Posted by lockiedownunder Jun 30, 2009
- 980 views
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)
4. Re: Encrypting image files
- Posted by mic_ Jun 30, 2009
- 979 views
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.
5. Re: Encrypting image files
- Posted by lockiedownunder Jun 30, 2009
- 1001 views
WAY over my head. I understand what your saying but would not have a clue on how to achieve this.
6. Re: Encrypting image files
- Posted by ChrisB (moderator) Jun 30, 2009
- 985 views
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
7. Re: Encrypting image files
- Posted by lockiedownunder Jul 01, 2009
- 1009 views
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?
8. Re: Encrypting image files
- Posted by Dan_M Jul 01, 2009
- 1004 views
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
9. Re: Encrypting image files
- Posted by lockiedownunder Jul 03, 2009
- 1003 views
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)
10. Re: Encrypting image files
- Posted by mic_ Jul 03, 2009
- 1009 views
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
11. Re: Encrypting image files
- Posted by Dan_M Jul 07, 2009
- 991 views
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)