13,833,727 members
See more:
Hello
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

Thanks

What I have tried:

I tried but did not get anything
Posted
Updated 17-Apr-18 3:52am

## 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[^]
Good luck :)
v3
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).

## Solution 3

Quote:
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

## 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

## 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: https://www.dotnetperls.com/image.
It is possible however to convert an Image to some other Type, e.g. a Byte[] array, see example here: https://stackoverflow.com/questions/3405138/working-with-image-and-bitmap-in-c

If you want to work pixel based you can use the GetPixel() method, but this will make your code very slow, see example here: https://www.codeproject.com/Articles/33838/Image-Processing-using-C
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 https://stackoverflow.com/questions/3405138/working-with-image-and-bitmap-in-c
Thanks

Top Experts
Last 24hrsThis month
 OriginalGriff 170 CPallini 70 Santosh kumar Pithani 70 Dave the Golfer 60 Maciej Los 55
 OriginalGriff 3,854 Maciej Los 1,825 RickZeeland 1,550 Richard MacCutchan 1,433 Wendelius 1,000