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.
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.
The easiest way to determine the GCD of two positive integers is by using Euclid’s algorithm
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
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
- 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
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.
Each module weighs 8 points. Deduction rules are as follows:
- If one misses half of a module, 4 points are deduced.
- If a module works with fixed inputs, 2 points deduction will be applied.
- If a module works marginally (which means some data are fine while others are not), 2 points deduction is then applied.
- If input validation doesn’t work properly, 1 point will be deducted.