使用Pycrypto for SSH

时间:2018-12-13 13:00:48

标签: python pycrypto

将公钥写入文件时出现错误。请让我知道解决方法。

from Crypto.PublicKey import RSA
key = RSA.generate(2048)
with open("private.key", 'wb') as content_file:
    chmod("private.key", 0o600)
    content_file.write(key.exportKey('PEM'))
pubkey = key.publickey()
with open("public.key", 'wb') as content_file:
    content_file.write(pubkey.exportKey('OpenSSH'))

错误如下

TypeError: can't concat str to bytes

0 个答案:

没有答案