Good Day Everybody! is there a way to solve the decoding problem after passing the keys, the code working fine with encrypted and decrypted but once i start select the publick key from data base shows me this problem. i have change the data type everything good different error in same line plain = [chr(pow(char ** key) % n) for char in ciphertext] the error im getting TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
Suppose the data from database is
data=16502916241650364826125871181879125871246803291624295583281818234716503551129558335511291624181879181879246803125871295583304595291624291624181879295583181496181496184182295114292940
key=117535
n=365867
private_key=113503
p=643
q=569
it's suppose to give me out put this: b7bcd0d379f2b5957003d947709¢Ó
the decryption code :
def decrypt(nn,pk, ciphertext):
#Unpack the key into its components
n=nn
key=pk
#Generate the plaintext based on the ciphertext and key using a^b mod m
plain = [chr((ord(char) ** key) % n) for char in ciphertext]
#Return the array of bytes as a string
return ''.join(plain)
if __name__ == '__main__':
'''
Detect if the script is being run directly by the user
'''
print("Your public key is ", public ," and your private key is ", private)
msg1=name
xxc=decrypt(n, key, msg1)
print(xxc)
print("\n")
in the end i'm sending the result of encrypted name is enc_name) and the public pair key picc and picc2
i have try change the data type of pk1=int(231761) and pk2=int(399089) but not working at all, and try for str also same problem. i have seen several posts of same related problem but the solution not working in same my case , such like here and here andhere andhere andhere none of these solutions are working with me. i'm using python 3.6 spyder
Any suggestion! thanks all