![]() ![]() ![]() Change this line d = calculate_d(phi, e)Īlso, since you asked for suggestions to improve your code, I made a few (a lot) improvements. It is solved when we invert the params of one of your function. I need the code to firstly encrypt the message with the encrypt function then decrypt it with the decrypt function, so the encrypted and original message should be displayed.Ĭould someone tell me whats wrong with my code (since I'm still in school, it may need to be simplified), any additional feedback would be greatly appreciated.Īfter a bit of debugging, the problem is that the function calculate_d() does not seem to calculate the right number. Q = int(input("Enter a key - this must be a prime number between 0 and 500:\n"))Įncrypted_message, N, e = encrypted, encrypted, encrypted ![]() P = int(input("Enter a key - this must be a prime number between 0 and 500:")) Message = input("Enter a message to encrypt:")Ĭhoice = input("Do you want to: \nA: enter a key \nB: use a random key?\n") The encryption function works to produce what looks like a feasible output but when I put it into the decryption function it either doesn't return the message correctly or gives me this error: ValueError: chr() arg not in range(0x110000) I've based the code off of the formulae c = m^e(mod N) and (c^d)mod N. ![]() I'm currently coding a simplified RSA algorithm for a project at school but can't get it to work. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |