我正在尝试解密使用3DES加密的python中的字符串。它是由我的正式伙伴用VB.net加密的。我不知道发生了什么。VB.net中的部分代码是
Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}
Private objTripleDES As New clsTripleDES(key, iv)代码类似于https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1564&lngWId=10
可以在python中解密吗?我需要使用bytearray吗?
发布于 2016-08-12 08:43:07
这样如何:
from Crypto.Cipher import DES3
key = [
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24
]
iv = [65, 110, 68, 26, 69, 178, 200, 219]
keyStr = ""
ivStr = ""
for i in key:
keyStr += chr(i)
for i in iv:
ivStr += chr(i)
encr = DES3.new(keyStr, DES3.MODE_CBC, ivStr)
decr = DES3.new(keyStr, DES3.MODE_CBC, ivStr)
#Outputs "1234567891234567"
print decr.decrypt(encr.encrypt("1234567891234567"))您应该调查在VB代码中使用哪种模式进行加密。根据this的说法,CBC是默认模式,但你不能确定。当您弄清楚所使用的模式时,请参阅this。
https://stackoverflow.com/questions/38869018
复制相似问题