如何显示加密的图像 [英] how to display the encrypted image

查看:165
本文介绍了如何显示加密的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要示例程序来显示加密的图像,请帮助我

这是用于加密的代码.但是我收到了诸如密钥在指定状态下无效"之类的错误消息

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"

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);


如何纠正?

在问题本身中添加了用户注释[/edit]


how to rectify it?

Added the user comments to the question itself[/edit]

推荐答案

如果您不知道加密标准和密钥/密码/等.用于对原始图像进行编码,如果没有一些严重的黑客技巧,您将无法对其解密(并且在许多情况下,即使具有这种技巧也无法实现).

该论坛中有一个代码示例,展示了如何在2个小型项目中同时实现加密和解密:
加密和解密图像
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


显示加密的图像首先,您必须将其解密"为原始格式.

为此,您必须知道所使用的加密方法和密钥.

.net中的标准库可以显示大多数图像格式(png,jpg,gif等)而不会出现问题.
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.


RSA只能加密短于密钥长度的数据块.尝试使用AES并使用带有AES的随机密钥对数据进行加密,然后使用RSA密钥对随机密钥进行加密.
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.


这篇关于如何显示加密的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆