this is the duction where datajs is a json
def encrypt(datajs, pub_key):
keyPub = RSA.importKey(pub_key) # import the public key
cipher = Cipher_PKCS1_v1_5.new(keyPub)
# print(cipher.encrypt.__doc__)
cipher_text = cipher.encrypt(datajs.encode()) # now we have the cipher
cipher_text = cipher_text.decode()
print(type(cipher_text))
print(cipher_text)
return cipher_text
this is the error showing
Traceback (most recent call last):
File "C:\Users\rahul.cs\PycharmProjects\pythonProject3\main.py", line 106, in <module>
encrypted = encrypt(datajs, pubkey)
File "C:\Users\rahul.cs\PycharmProjects\pythonProject3\main.py", line 63, in encrypt
cipher_text = cipher_text.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x95 in position 0: invalid start byte