English 中文(简体)
三维服务供应商和
原标题:TripleDESCryptoServiceProvider and

我使用 < code> TripleDESCrypto ServiceProvider 来加密数据,我注意到一件事,当我使用数据解密数据时,数据有时以一系列 < {{{{{{{{{{{{{{{{{{{{{{{}}字符结束。所以,如果我加密 ,然后解密这个加密版本,我就能返回 。这有问题吗?

最佳回答

您的加密方法可能正在添加一些垫子, 在此情况下是零垫子 。 您的解密方法没有预想着垫子, 所以它只是解密它, 好像它是原始平文本的一部分 。

DES 是一个区块密码器, 只能使用 64 位( 8 字节) 区块中的数据。 任何纯文本都添加到下一个区块边界 。

Zero 贴布并不好, 因为如果纯文本以零字节结尾, 您就会遇到问题( 如 C型字符串) 。 改变您的加密方法以添加 < a href=" http:// en. wikipedia. org/ wiki/ Pateding_ 28cryptgraphy% 29 # Byte_ padding” rel= “ nofollow” > PKCS# 5 贴布 < / a >, 并改变您的解密方法来期待同样的结果 。 然后会自动删除这一贴布, 您永远不会看到它 。

问题回答

暂无回答




相关问题
Extend Contacts application on Android to provide encryption

I want to encrypt individual contacts stored by the Contacts application on Android based on user s preference. So, I am thinking I ll have to hook/extend the Contacts application before the it stores ...

Make md5 strong

Im making a website that will intergrate with game that only support md5 hashing metod (atm). Which ofc is not especially safe anymore. But how could i make it stronger? Should I just generate long ...

How to Pack/Encrypt/Unpack/Decrypt a bunch of files in Java?

I m essentially trying to do the following on a Java/JSP-driven web site: User supplies a password Password is used to build a strongly-encrypted archive file (zip, or anything else) containing a ...

Thread & Queue vs Serial performance

I though it ll be interesting to look at threads and queues, so I ve written 2 scripts, one will break a file up and encrypt each chunk in a thread, the other will do it serially. I m still very new ...

Convert PHP encryption code to C#

I m trying to convert this piece of code from PHP to C#. It s part of a Captive Portal. Could somebody explain what it does? $hexchal = pack ("H32", $challenge); if ($uamsecret) { $newchal = ...

Encryption: how to have 1 iv despite multiple fields

I ve been stuck trying to arrive at a best solution for this for a while. I know that an initialization vector has to be unique for each item being encrypted. So if I m encrypting an address and I ...