使用https://raw.github.com/usefulfor/usefulfor/master/security/JBoss.java上的代码,我做了以下工作:
bash-3.2$ java -cp . JBoss -e testpython
-27038292d345798947e2852756afcf0a
bash-3.2$ java -cp . JBoss -d -27038292d345798947e2852756afcf0a
testpython
Run Code Online (Sandbox Code Playgroud)
但是,我不能为我的生活,弄清楚如何使用python中的pycrypto解密字符串'27038292d345798947e2852756afcf0a'.我的理解是Java代码使用的是Blowfish,而"jaas就是这种方式"作为密码的关键.但我无法理解如何在python中执行此操作.以下结果导致大多数不可打印的垃圾:
import Crypto
from Crypto.Cipher import Blowfish
from base64 import b64encode, b64decode
bs = Blowfish.block_size
key = 'jaas is the way'
plaintext = b'27038292d345798947e2852756afcf0a'
iv = '\0' * 8
c1 = Blowfish.new(key, Blowfish.MODE_ECB)
c2 = Blowfish.new(key, Blowfish.MODE_CBC, iv)
c3 = Blowfish.new(key, Blowfish.MODE_CFB, iv)
c4 = Blowfish.new(key, Blowfish.MODE_OFB, iv)
msg1 = c1.decrypt(plaintext)
msg2 = c2.decrypt(plaintext)
msg3 = c3.decrypt(plaintext)
msg4 = c4.decrypt(plaintext)
print …Run Code Online (Sandbox Code Playgroud)