Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,I am in need of sample program to display the encrypted image ,someone pls help me

This is the code for encryption.But I got a error like "key not valid for use in specified state"
C#
byte[] img = imagetobyte(pictureBox1.Image);
RSAParameters rsaPubParams;
RSAParameters rsaPrivateParams;
RSACryptoServiceProvider rsaCSP = new RSACryptoServiceProvider();

//Generate public and private key data.
rsaPrivateParams = rsaCSP.ExportParameters(true);
rsaPubParams = rsaCSP.ExportParameters(false);
rsaCSP.ImportParameters(rsaPubParams);
byte[] output=new byte[13000000];
output = rsaCSP.Encrypt(img,false);
pictureBox2.Image = byteArrayToImage(output);

how to rectify it?

[Edit: Codehawkz]Added the user comments to the question itself[/edit]
Posted
Updated 19-Sep-12 22:39pm
v2
Comments
Kuthuparakkal 20-Sep-12 2:41am    
need more info
prabhatsp 20-Sep-12 2:49am    
I need the program which use image(flower something) as input , i want perform encryption process with key and image.Then I have to display the encrypted image(something like image full of dot,but something to be displayed) as output
prabhatsp 20-Sep-12 3:21am    
The code using AES Encryption performs encryption ,but the image will not be displayed.
DaveAuld 20-Sep-12 2:41am    
That is just a horrendous question. What encryoted image? What encryption scheme? What have you tried?
prabhatsp 20-Sep-12 2:49am    
I need the program which use image(flower something) as input , i want perform encryption process with key and image.Then I have to display the encrypted image(something like image full of dot,but something to be displayed) as output

If you do not know the encryption standard and the keys/passwords/etc. used to encode the original image, you will not be able to decrypt it without some serious hacking skills (and in many cases, it's not possible even with such skills).

There's a code sample in this forum that shows how to implement both encryptions and decryption in 2 small projects:
Encrypt and decrypt images
 
Share this answer
 
To show an encrypted image first you must "decrypt" it to the original format.

For this you must know the encryption method and keys used.

The standard libraries in .net can show most image formats (png,jpg,gif etc.) without problems.
 
Share this answer
 
Comments
DaveAuld 20-Sep-12 2:55am    
Reading his comments, I think he is talking more about image scrambling, as he wants to still be able to show a valid image of the encrypted input image.
RSA can only encrypt data blocks that are shorter than the key length. Try AES and encrypt the data using a random key with AES and encrypt the random key with RSA key.
 
Share this answer
 
Comments
Kuthuparakkal 20-Sep-12 3:28am    
I think you are confused with encryption and "the stuff" you would like to achieve. You either look for :
1. Image Distortion

OR
2. Scramble/De-scarmble stuffs.

http://www.codeforge.com/article/211089
http://en.wikipedia.org/wiki/Bilinear_interpolation

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900