所以我试图解密我在 Python 中用 JS 加密的字符串。我用过aes-js图书馆。我明白了:caba6777379a00d12dcd0447015cd4dbcba649857866072d。这是我的JS代码:
var key = aesjs.utils.utf8.toBytes("ThisKeyIs16Bytes");
console.log(`Key (bytes): ${key}`);
var text = 'psst... this is a secret';
var textBytes = aesjs.utils.utf8.toBytes(text);
var aesCtr = new aesjs.ModeOfOperation.ctr(key, new aesjs.Counter(5));
var encryptedBytes = aesCtr.encrypt(textBytes);
var encryptedHex = aesjs.utils.hex.fromBytes(encryptedBytes);
console.log(`Hex: ${key}`);
我已经在 python 中尝试了一些东西,但这就是我目前所拥有的:
from Crypto.Cipher import AES
ciphered_data = bytearray.fromhex('caba6777379a00d12dcd0447015cd4dbcba649857866072d')
key = b'ThisKeyIs16Bytes'
cipher = AES.new(key, AES.MODE_CTR)
original_data = cipher.decrypt(ciphered_data)
print(original_data.decode("utf-8", errors="ignore"))
但我收到的只是一团糟。=*լ☻ve↕-:tQɊ#¶。
翻过高山走不出你
相关分类