Try to provide an easy explanation as I am a newbie in Python. Print ("Decrypting message with public key ", public ,". Can someone please help in parallelizing the decrypt function loop and make the program faster Since the decrypt function is calculating large numbers the calculation is really consuming a lot of time. Plain = ĭetect if the script is being run directly by the user #Generate the plaintext based on the ciphertext and key using a^b mod m Print (''.join(map(lambda x: str(x), encrypted_msg)))ĭecryption code: def decrypt(k,pk, ciphertext): Print ("Your public key is ", public ," and your private key is ", private)Įncrypted_msg = encrypt(private, message) Print ("Generating your public/private keypairs now. #Convert each letter in the plaintext to numbers based on the character using a^b mod mĬipher = #Public key is (e, n) and private key is (d, n) #Use Extended Euclid's Algorithm to generate the private key #Use Euclid's Algorithm to verify that e and phi(n) are comprime #Choose an integer e such that e and phi(n) are coprime Raise ValueError('p and q cannot be equal') Raise ValueError('Both numbers must be prime.') When i use the public key for decryption the data is wrong!! i have also try use private same also wrong!! any suggestion ! Is there away to solve this problem even the code is work prefect for encrypted and decrypted the data when they are in same file, the problem happen when i divide the code into two parts, one part encryption and second part decryption, but still i'm getting wrong decryption data even i use same public key and n value was generated in encryption part.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |