Reputation: 115
I'm encrypting and decrypting images because they contain sensitive information.
My struggle here is that I cant do the standard Process.Start(saveImagePath);
because the of the encryption.
So far my solution is to just make a Windows Form that opens it in PictureBox
because it doesn't require a path and I can just do this:
newImage = enc.Decrypt();
pictureBox1.Image =newImage;
But it's been a struggle trying to simulate Windows Photo Viewer.
My question is, can I open an image with just the image newImage = enc.Decrypt();
without the path in Windows Photo Viewer (or any other similar software), or am I doomed to try and replicate a Photo Viewer program?
Upvotes: 2
Views: 551
Reputation: 25351
Let me start by saying that if the images information is highly sensitive, then there is no way to display it to the user and ensure its security 100%. Even with a memory stream, one can make a memory dump and access the sensitive info. That's not trivial, but doable.
Now that's out of the way, Windows processes cannot directly access each other's memory without going through privileged debug-like API functions like ReadProcessMemory
. This is what keeps Windows stable and secure, but makes what you are trying to accomplish not doable. You have to use a file.
Others suggested saving the file in the Windows Temporary folder. That's not any more secure than saving it in any other folder like you're doing. A little more secure way is to create a RAM-Disk, save the files there, display them, and then remove the RAM-Disk.
The RAM-Disk is an in-memory simulation of a hard-disk and you can access it in the same way with a drive letter. Creating and then removing a RAM-Disk isn't a trivial task, and it only offers a little more security, but you're the only one who can decide whether it is worth it. The user can still see and access the files on the RAM-Disk, but only before it is removed. So the only added security it offers is reducing the window during which the user can directly access the files.
Opening the images in your own app like you're doing is still the most secure way, as the only way to extract those files is by making a memory dump, and that's really hard with images (it's easier with text). You can search for some library if you don't want to code it all by yourself.
Upvotes: 2