-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