所以我能够使它在CryptoJS的javascript中工作
var key = CryptoJS.enc.Latin1.parse("m6h6dTeZavubd74U");
var oldData = CryptoJS.enc.Hex.parse(16BA1AE9044682B675B1324F4BB311AB13D95B393AA46B4F038E4632936F3D848A959BDE4537629833B4FA085B6A333754FFC9ACBF1747A799D1102534CE335791133E9FCFB563BAFB8F53719F9550BD25A0B862D37CEC185E66273B73DB0D86F9CAF5D2BFFB3C4C3950C209BDFF54B1F7B4649389BD83FC01EE8FEA2D908F6C51F5578931C6A71341B23307BADB5F2D4ABE3B6BC61A100E359D7FE28CFF287210C0178C69CC8204F448CBFCD0E8AD573D895D9B453CBCEB2254E372B96295D0E2CD51924B5BC71BF27DE1E7086CD0988617D3ADEC3AAE9C382E1988B4D12125314B578A7DBC0CCE9661CE51C4D7162DAA82FF7255C44B538A5071966BC747522320C6E5FECED5C773678CB4A2D63D92F5142DE0850632ABDAD5AEDC35E83A551388C244703FC7C83D41856528C11B1AF8B39F71ADCC8E4747394CBAE9910FA3DB666AF0A249CBCE1A7F0987A29E072AC521078300854C7C86A8EF9C1425E64838E9B6B0C5251FD395C9AA244AF1B63B4D7D6A334B045FD990744E8CE04D466568133B7D0CB82B638DBF0C1F05DDA2B751E828A0F7B735E77323EAB0205F6B76E806A1054B8409EEA5C3864E12A543DB0A8D06580A2DC9236A6CBB0A0CD17DAD72C5C547EE51697B0EAFCA4A9E538EA3DF8FD4636A622731741AC2EC01E737563BEDF4B7EB1A46F07C28AC6F7625F5CE39F28F5774AD88092178BE01D4A6685BC5693B024A52AD1250773C820FAF46FA1CB35B36AAAAB57F1EE1A67001B65EEDDA6D7CA7576DF249BFE1958E0DD73B31DA552E3F952BC699E0ACFCDDB8098F42E4E59AF579BA6D7B98DE0865A2E3C80DBDD100BC3F5DA8E009A3FC251D6FE78D);
var nextData = CryptoJS.AES.decrypt( { ciphertext: oldData}, key, { iv: key })
var plaintext = nextData.toString(CryptoJS.enc.Utf8);
哪个给了我
的JSON输出{"widget": { "debug": "on", "window": { "title": "Sample Konfabulator Widget", "name": "main_window", "width": 500, "height": 500 }, "image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center" }, "text": { "data": "Click Here", "size": 36, "style": "bold", "name": "text1", "hOffset": 250, "vOffset": 100, "alignment": "center", "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" }}}
但是我对Python不太熟悉,但是我想知道是否可以在python中进行相同类型的AES解密。谢谢
答案 0 :(得分:0)
这几乎是一个答案,并且可能是您解决方案的起点。
您必须使用以下方法安装加密模块:
pip install cryptography
消息几乎正确解密。
我的前几个字节有一个解密错误。也许其他人可以查明加密设置,这将解决此问题。 也许其他人知道出了什么问题。
import codecs
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
backend = default_backend()
key = "m6h6dTeZavubd74U"
msg = "16BA1AE9044682B675B1324F4BB311AB13D95B393AA46B4F038E4632936F3D848A959BDE4537629833B4FA085B6A333754FFC9ACBF1747A799D1102534CE335791133E9FCFB563BAFB8F53719F9550BD25A0B862D37CEC185E66273B73DB0D86F9CAF5D2BFFB3C4C3950C209BDFF54B1F7B4649389BD83FC01EE8FEA2D908F6C51F5578931C6A71341B23307BADB5F2D4ABE3B6BC61A100E359D7FE28CFF287210C0178C69CC8204F448CBFCD0E8AD573D895D9B453CBCEB2254E372B96295D0E2CD51924B5BC71BF27DE1E7086CD0988617D3ADEC3AAE9C382E1988B4D12125314B578A7DBC0CCE9661CE51C4D7162DAA82FF7255C44B538A5071966BC747522320C6E5FECED5C773678CB4A2D63D92F5142DE0850632ABDAD5AEDC35E83A551388C244703FC7C83D41856528C11B1AF8B39F71ADCC8E4747394CBAE9910FA3DB666AF0A249CBCE1A7F0987A29E072AC521078300854C7C86A8EF9C1425E64838E9B6B0C5251FD395C9AA244AF1B63B4D7D6A334B045FD990744E8CE04D466568133B7D0CB82B638DBF0C1F05DDA2B751E828A0F7B735E77323EAB0205F6B76E806A1054B8409EEA5C3864E12A543DB0A8D06580A2DC9236A6CBB0A0CD17DAD72C5C547EE51697B0EAFCA4A9E538EA3DF8FD4636A622731741AC2EC01E737563BEDF4B7EB1A46F07C28AC6F7625F5CE39F28F5774AD88092178BE01D4A6685BC5693B024A52AD1250773C820FAF46FA1CB35B36AAAAB57F1EE1A67001B65EEDDA6D7CA7576DF249BFE1958E0DD73B31DA552E3F952BC699E0ACFCDDB8098F42E4E59AF579BA6D7B98DE0865A2E3C80DBDD100BC3F5DA8E009A3FC251D6FE78D"
def decrypt(key_aslatin1, msg_as_ascii_hex):
msg = codecs.decode(msg_as_ascii_hex, "hex")
key = key_aslatin1.encode("latin1")
iv = key
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
decryptor = cipher.decryptor()
rslt_bytes = decryptor.update(msg) + decryptor.finalize()
rslt = rslt_bytes.decode("utf8")
return rslt
print(decrypt(key, msg))
显示的输出是:
_3.CLUnu "debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}