So youll have to convert them to normal str objects. basicly i m trying to make this to decrypt a message in encrptedmsg. :raise DecryptionError: when the decryption fails. I am trying to write RSA encryption and decryption in python without Crypto library and in short I have generated public(e,N) and private(d,N) keys to exchange with message and I don't know how to that. Your items in secretkeys are bytes, which are not JSON serializable. encrypt :param privkey: the :py:class:rsa.PrivateKey to decrypt with.