Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CMSC 55 Machine Exercise Implement the RSA algorithm that accepts a series of three single digit numbers.

Each number is to be encrypted/decrypted via RSA. The program will let the user input the 2 prime numbers, p and q, and the message itself. Here is a sample run: Enter first prime: 37 Enter second prime: 43 This is n: 1591 This is phi: 1512 This is e: 5 This is d: 605 Enter character 1: 7 Enter character 2: 8 Enter character 3: 9 -----------------------------Encryption: 897948182 Decryption: 789 ALGORITHM: select two large primes at random - p,q compute their system modulus n=p.q -define (n)=(p-1)(q-1) select at random the encryption key e where 1<e<(n), gcd(e,(n))=1 solve following equation to find decryption key d (e*d)% (n)=1 and 0dn To encrypt: me%n = c To decrypt: cd%n = m

You might also like