加密数据中的空字符 [英] Null character in encrypted data
问题描述
在进行cbc加密后,空字符是否有可能出现在所得的多字节数据中.如果是,我应该采取什么预防措施来避免这种情况.
Is it possible that after cbc encryption, null character appears in the resulting multibyte data. If yes, what precaution should I take to avoid it.
推荐答案
在进行cbc加密之后,是否有空字符出现在生成的多字节数据中.
Is it possible that after cbc encryption, null character appears in the resulting multibyte data.
绝对.如果缺少0之类的值,它将不是伪随机函数.
Absolutely. It would not be a pseudo-random function if values like 0's were missing.
如果是,我应该采取什么预防措施来避免这种情况.
If yes, what precaution should I take to avoid it.
将所有内容作为带有嵌入式NULL
的byte
数组进行处理.切勿将其视为char*
.
Treat everything as a byte
array with embedded NULL
s. Never treat it like a char*
.
如果要将其视为char*
,则需要先对其进行编码.尝试使用十六进制,Base32或Base64.
If you want to treat it like a char*
, then you will need to encode it first. Try hexadecimal, Base32 or Base64.
这篇关于加密数据中的空字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!