如何使用 RijndaelManaged 和 PKCS5 填充在 vb.net 中加密字符串? [英] How do I encrypt a string in vb.net using RijndaelManaged, and using PKCS5 padding?
问题描述
我用下面的代码来初始化加密...
I use the following code to initialize encryption...
Dim symmetricKey As New System.Security.Cryptography.RijndaelManaged()
With symmetricKey
.Key = Encoding.ASCII.GetBytes(Key)
.IV = Encoding.ASCII.GetBytes(IV)
.Mode = CipherMode.CBC
.BlockSize = 128
.KeySize = 128
.Padding = PaddingMode.PKCS7
End With
要求是使用 PKCS5.vb.net 中的填充模式仅包括
The requirement is to use PKCS5. Padding modes in vb.net only include
- ANSIX923
- ISO10126
- 没有
- PKCS7
- 零
所以我认为 PKCS5 没有方法.有什么办法可以添加,还是需要自己写一个加密方法?如果是这样 - 我该怎么写?是否有可靠的 DLL 支持它?
So I don't think there is a method for PKCS5. Is there any way to add it, or do I need to write an encryption method myself? If so - how do I write that? Is there a reliable DLL that will support it?
推荐答案
PKCS7 填充和 PKCS5 填充是一回事.在这种情况下,它们是同义词.
PKCS7 padding and PKCS5 padding are the same thing. In this context they are synonyms.
PKCS#7 填充在 PKCS#7 规范中描述第 10.3 节.PKCS#5 填充在 PKCS#5 规范的第 6.1.1 节中进行了描述步骤 4. 通过检查可以看到,填充算法是相同的.
The PKCS#7 padding is described in the PKCS#7 spec in section 10.3. PKCS#5 padding is described in the PKCS#5 spec in section 6.1.1 step 4. As you can see by examination, the padding algorithms are identical.
这篇关于如何使用 RijndaelManaged 和 PKCS5 填充在 vb.net 中加密字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!