-3
我试图解码用Java编码的消息。下面是代码从我们的Java开发人员的代码片段:使用Python解码消息3
$encrypted = base64_decode(urldecode($value));
$decrypted = "";
openssl_private_decrypt($encrypted, $decrypted, $key);
我试图解码使用Python与私有密钥字符串:
from Crypto.Cipher import PKCS1_OAEP
from Crypto.PublicKey import RSA
import base64
from urllib.parse import unquote
private_key="Private_key"
cipher = PKCS1_OAEP.new(private_key)
mesg='some mesg'
# For URL encoder
a=unquote(mesg)
encrypted=base64.b64decode(a.encode("utf-8"))
# before decrypt convert the hex string to byte_array
message = cipher.decrypt(bytearray.fromhex(encrypted))
print(message)
我收到以下错误,而我使用Python 3
TypeError: fromhex() argument must be str, not bytes
我不知道,但你只是把你的私钥粘贴到stackoverflow? –
是什么让你觉得这是Java? – user2357112
请确保使该私钥失效并将其替换为新私钥。 – poke