如何加密图片以使其显得混乱? [英] How to encrypt a picture so that it appears confused?

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

问题描述

您好

我想加密图像,使其成为未更改或更改其标题的图像文件

但我有加密问题图像没有打开,我希望它打开,但条件是它很混乱





任何人都可以用适当的方式帮助我代码,这是一个加密代码,而不是图像处理



我尝试过:



 //此代码由算法DES使用







 pictureBox1.Image = image; 
MemoryStream ms = new MemoryStream();
image.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);

byte [] bytes = ms.ToArray();
BitArray bitArray = new BitArray(bytes);
for(var x = 5000; x< 9000; x ++)
textBox1.Text + = Convert.ToInt16(bitArray [x]);
MD5CryptoServiceProvider mds = new MD5CryptoServiceProvider();
// UTF8Encoding utf8 = new UTF8Encoding();
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
//tdes.Key = mds.ComputeHash(utf8.GetBytes(textBox1.Text));
tdes.Mode = CipherMode.CBC;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform tram = tdes.CreateEncryptor();
encrypted =(tram.TransformFinalBlock(bytes,0,(bytes.Length)));
//MessageBox.Show(Convert.ToString(encrypted));
File.WriteAllBytes(E:/u.jpg,加密);

解决方案

基本上,在视觉上使图像全部消息是不值得的。



加密图像几乎是不可能的,并且它仍然具有与原始图像完全相同的尺寸。要做到这一点,你将被限制为弱加密方法,导致一对一的字节,如替换密码。


我将缩短我的问题所有我想要显示我这样加密后的照片



分组密码操作模式 - 维基百科 [ ^ ]

Hello
I want to encrypt the image so that it is as an image file that has not changed or changed its header
But I have a problem with encryption is that the image does not open and I want it to open but on condition that it is confused


Can anyone help me with the appropriate code so that it is a cryptographic code and not an image processing

What I have tried:

//This code was used by an algorithm DES 




pictureBox1.Image = image;
           MemoryStream ms = new MemoryStream();
           image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

           byte[] bytes = ms.ToArray();
           BitArray bitArray = new BitArray(bytes);
           for (var x = 5000; x < 9000; x++)
               textBox1.Text += Convert.ToInt16(bitArray[x]);
           MD5CryptoServiceProvider mds = new MD5CryptoServiceProvider();
           //UTF8Encoding utf8 = new UTF8Encoding();
           TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
           //tdes.Key = mds.ComputeHash(utf8.GetBytes(textBox1.Text));
           tdes.Mode = CipherMode.CBC;
           tdes.Padding = PaddingMode.PKCS7;
           ICryptoTransform tram = tdes.CreateEncryptor();
           encrypted = (tram.TransformFinalBlock(bytes, 0, (bytes.Length)));
           //MessageBox.Show(Convert.ToString(encrypted));
           File.WriteAllBytes("E:/u.jpg", encrypted);

解决方案

Basically, it's not worth the effort to make the image "all message up" visually.

It's virtually impossible to encrypt the image and have it still have the exact same dimensions as the original image. To do that, you'd be limited to weak encryption methods that result in a one-for-one byte, like a substitution cipher.


I will shorten my question all I wanted to show me the picture after the encryption like this

Block cipher mode of operation - Wikipedia[^]


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

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