Click here to Skip to main content
13,833,727 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am a new member
I like the site very much

I am currently working on a graduation project and a site to encrypt images c#
But I have a problem converting the image into int and then bit to be able to insert it into the algorithm
Does anyone help me please


What I have tried:

I tried but did not get anything
Updated 17-Apr-18 3:52am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

See article here: File Encryption and Decryption in C#[^]
If your site is hosted, this article might be interesting: Using RSA Public Key Encryption in a Shared Web Hosting Environment[^]
If performance is important, then read this article: Swanky Encryption/Decryption in C#[^]
Good luck :)
Member 13780784 17-Apr-18 7:46am
Thank you so much.
These links talk about encoding files and texts in general, I benefited from them, but my project is the work of the site (encrypt images).
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

How to convert pixels to binary?

But pixels are already binary, What you mean ?
An image stored to file is like any file, so any file encrypting technique works with images.
From encryption point of view, any file is a string of byte, no more no less.

My advice: Save the image to file, and then encrypt the file. tools for both operations are standard.
Member 13780784 17-Apr-18 12:04pm
Thank you for the information about Pepolymorphe and thank you also for the advice

Just for illustration ^ _ ^
What I mean is that it reads the pixels (byte) and converts them to int and then to bits
Then enter it into an encryption algorithm such as DES

The output of the algorithm has an inverse operation which returns it to the int and then to the pixels (to get the encrypted image)
This idea was given to me by the supervisor. I'm not convinced of it, but she asked for it.

The whole idea is that we have a picture that we turn it into a new image that no one can read.
Or make it an image that can not be opened
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

With C# encryption algorithms usually take a number of bytes (a single one or an array of bytes) as input for a Write() function. They don't care about the kind of data that is represented by the input.

So all you have to do is converting images to a byte array as described at C# Image to Byte Array and Byte Array to Image Converter Class[^] or when the image is stored as file open that for reading as shown in the first link of solution 1.
Member 13780784 17-Apr-18 12:57pm
Thank you Jochen Arndt for helping me a lot

I think that's what I'm looking for

I repeat my thanks
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

My question
How to convert pixels to binary?
What is the appropriate code in c# ?
RickZeeland 17-Apr-18 8:52am
Usually the Image type is used for working with pictures, see examples here:
It is possible however to convert an Image to some other Type, e.g. a Byte[] array, see example here:

If you want to work pixel based you can use the GetPixel() method, but this will make your code very slow, see example here:
Member 13780784 17-Apr-18 11:34am
Thanks, this is useful
But I tried this before I did not get what I wanted
On the whole thank you very much RickZeeland
pleasure for me to see you
I will try again the codes found in this link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190114.1 | Last Updated 17 Apr 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100