逐块读取和解密DES加密文件。 [英] Reading and Decrypting DES encrypted file block by block.

查看:143
本文介绍了逐块读取和解密DES加密文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在.NET 4.0中编写一个演示应用程序,它允许用户使用DES加密来加密文件。这部分我已经完成了。



现在,我想以8字节的块读取同一个文件,并在每个块被解密时向用户显示输出。我故意不想破译整个文件。



我使用ECB进行加密模式,因此不使用盐值。块大小也是64位,填充模式是PKCS7。

解决方案

这不是加密的工作原理。如果你想这样做,你应该分别加密那些8字节的块,如果这么小的块大小,这几乎不可行。我首先想到的是,这是你真正想要的。毕竟,如果用户可以获得任何8字节的解密块,则可以通过一些编程工作轻松获取整个文件。我个人能够做到这一点。那么,有什么意义呢?



我认为正确的解决方案应该在一个不同的方向:你需要根据整体方法分析你的安全方案,整个事情,从理论上审查可能的漏洞,然后整体解决问题。如果您希望我们中的一些人为您提供帮助,您可能需要详细描述您的工作方案和要求。



-SA

I'm writing a demo application in .NET 4.0 which allows user to encrypt a file using DES encryption. This part I have completed.

Now, I want to read that same file in blocks of 8 bytes and display the output to the user as each block is deciphered. I intentionally don't want to decipher the whole file.

I'm using ECB for encryption mode hence no salt value is used. Also the Block size is 64 bits and padding schema is PKCS7.

解决方案

This is not how encryption works. If you want to do that, you should encrypt those 8-byte blocks separately, which hardly can be practical, in case of such a small block size. I would first think if this is what you really want. After all, if a user can get any of 8-byte of decrypted block, someone can pretty easily obtain the whole file by doing some programming work. I would personally be able to do that. So, what's the point?

I think the right solution should lies in some different direction: you need to analyze your security scenarios based on holistic approach, the whole thing, review possible exploits theoretically and then address the problem as a whole. If you want some of us to help you, you probably need to describe your working scenarios and requirements in detail.

—SA


这篇关于逐块读取和解密DES加密文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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