我从java导入了一个公钥到python我使用的是sockets
在java中,我使用RSA/ECB/PKCS1Padding
在python中,我使用Crypto
库
在变量server_public_key
中,我导入了公钥
在cipher
中,我使用PKCS1_OAEP
来加密消息
在ciphertext
中,我加密消息
然后我就把它变成了一个告别
然后我把它送回爪哇
但是java发送这个错误Exception in thread "main" javax.crypto.BadPaddingException: Decryption error
这是我的密码
message = "SENDING TO JAVA"
s= socket.socket()
s.connect((address,9000))
data = s.recv(1024)
data = data[2:]
server_public_key = RSA.importKey(data)
cipher = PKCS1_OAEP.new(server_public_key)
ciphertext = cipher.encrypt(mensaje)
b = bytearray()
b.extend(ciphertext)
b = bytearray()
b.extend(ciphertext)
s.sendall(b)
当我删除正在发送的密文的第二个不可理解的副本,并清理并更正python代码时,它对我是有效的。这是我使用的python代码。在
演示这一点的小Java服务器是 在
^{pr2}$注意:^{} 来自googleGuava库。在
相关问题 更多 >
编程相关推荐