Commit 8bdee209 authored by Hristian Stoilov's avatar Hristian Stoilov
Browse files


Write a program in Java that is capable of the following:
1. One can generate an RSA key pair of realistic size. Therefore, the following steps are
(a) Two different primes are created and multiplied using the class BigInteger.
(b) A suitable e is chosen and the corresponding d is computed. In particular, you have
to implement the Extended Euclidean Algorithm.
(c) The private key is stored in a file sk.txt in the form (n, d) with n and d in decimal
representation. The public key is stored in a file pk.txt in the form (n, e).
2. One can read in a text file (ASCII) text.txt into a string and encrypt this string in the
following way:
(a) One reads in a public key from a file pk.txt.
(b) Every character of text.txt is converted to its ASCII code (number between 0 and
(c) Every such number is encrypted with the RSA scheme. In particular, you have to
implement the fast exponentiation algorithm.
(d) The encryptions are stored in a file cipher.txt (in decimal representation and separated
by a comma).
Remark: This character by character encryption is not secure as statistical analyzes are
possible. (The letter frequencies of the plain text coincide with those of the cipher text.)
RSA is in practice hence not used in that way but in a clever way in combination with a
symmetric scheme. This is part of the cryptography courses.
3. One can decrypt a file cipher.txt (that has been constructed in the way described above)
with a private key in sk.txt and store the resulting plain text in text-d.txt.
4. Decrypt the file cipher.txt with the secret key in sk.txt.
General notes:
1. You can work in groups of at most 3 people.
2. A complete solution yields a bonus of 0.3 on the grade of the first assessment. (The final
continuous assessment grade is, for technical reasons, between 1.0 and 6.0.)
3. The program should be comprehensibly commented.
4. I assume that, for fairness reasons, you do not try to cheat. However I will check this also
with tools. If I detect an attempt to deceive by submitting (disguised) copies of parts of
existing programs, taken from the Internet or fellow students, I will set the grade of the
next assessment to 1.0.
Submission deadline: 27.3.2017, 10:00 a.m.
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment