Public, private = generate_keypair( p, q) Print "Generating your public/private keypairs now. Q = int( raw_input( "Enter another prime number (Not one you entered above): ")) P = int( raw_input( "Enter a prime number (17, 19, 23, etc): ")) 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 #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.') Use iteration to make it faster for larger integersĮuclid's extended algorithm for finding the multiplicative inverse of two numbersįor n in xrange( 3, int( num ** 0.5) + 2, 2): Euclid's algorithm for determining the greatest common divisor
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |