## Requirement

Please write up a program in any language you like to realize the following 5 requirements. A GUI is helpful (please see the attached 2 examples). Please keep in mind, appropriate input(s) should be available and validated before execution to avoid unnecessary errors. Keys are generated based on user’s inputs.

## Calculate modulus and inverse modulus

1) For two positive integers a and p, calculate a mod p
2) A number a (>0) has an inverse a ^ -1 such that a × a ^ -1 = 1 (mod p): (Fermat’s Little Theorem)

``````given:  a mod p
where:  p = prime number
a < p
then:   inverse (a ^ -1)= ap-2 mod p
calculate a ^ -1.
``````

## Calculate Greatest Common Divisor (GCD) of two positive integers (a, b)

The easiest way to determine the GCD of two positive integers is by using Euclid’s algorithm

## Encrypt and Decrypt a simple message using Affine Mapping

Using a, b, c, …, z, and space (27 letters), your defined letter set, or the ASCII table to implement an affine mapping based encryption/decryption.

``````C = aP + b mod N
P = a'C + b' mod N
``````

## Encrypt and Decrypt a simple message using Digraph

Using a, b, c, …, z, and space (27 letters), your defined letter set, or the ASCII table to implement a digraph-based encryption/decryption.

``````C1 = a P1 + b P2 mod N
C2 = c P1 + d P2 mod N

P1 = a' C1 + b' C2 mod N
P2 = c' C1 + d' C2 mod N
``````

## Encrypt and Decrypt a simple message using R.S.A. (public/private keys generation)

• Divide the message into blocks (e.g., the simplest one: one letter/block) such that the bit string of each block can be viewed as a certain digit number.
• Call this block P.
• Public Key (E, n)
• Encrypt: C = P ^ E mod n
• Private Key (D, n)
• Decrypt: P = C ^ D mod n

## Delivery

Source codes and compiled executable demo program. Please zip all the files and then drop it to the Project 1 Dropbox. In case your program requires some special settings, please write me a note. So I can run and evaluate it properly.