i need to know the answer of this question cos we r getting one at least with the same idea and im totally blank
1. Encryption
a) Read a plaintext from a file plainText.txt
b) Create a Key: (Your plaintext character count)%11
c) Make cipher text: Shift all characters forward base on the key
(Example) plain text: ABC, Key = 3, cipher text: DEF.
d) Generate cipherText.txt (it should contain cipher text)
2. Decryption
a) Read a ciphertext from the file cipherText.txt
b) Retrieve the key
c) Retrieve the plain text: shift all characters backward base on the key
(Example) cipher text: DEF, Key=3, Plaintext = ABC.
e) Generate plain2.txt (it should contain the original plaintext)
Your program should have the Menu (Encryption, Decryption) for user interaction. Your program should ask user whether he wants to continue so It should never end unless the user enters “NO” or “no”.
Version 2:
Your program should do following operations:
1. Encryption
a) Read a plaintext from a file plainText.txt
b) Calculate the frequency of each letter, and sort all letters base on their frequency (highest to lowest)
c) Generate a Key: (sorted alphabet letters from step2)
d) Make cipher text: Swap each character with another random character
Note: avoid repetition
e) Generate cipherText.txt (it should contain cipher text)
2. Decryption
d) Read a ciphertext from the file cipherText.txt
e) Calculate the frequency of each letter, and sort all letters base on their frequency (highest to lowest)
f) Retrieve the plain text: Swap the most frequent letter with key’s first letter and so on.
g) Generate plain2.txt (it should contain the original plaintext)
Your program should have the Menu (Encryption, Decryption) for user interaction. Your program should ask user whether he wants to continue so It should never end unless the user enters “NO” or “no”.
Basing the key on letter frequency will only decipher correctly if we guarantee there will be no ties. What happens if there are 10 T's, 10 E's, 10 S's using random letters for the key. The more tied frequencies, the lesser chance of a successful decryption. The encryption is fine if you want to make one of those puzzles, crypt-o-gram's from newspapers, but decrypting will not be that easy. The program will need to apply trial and error methods to hopefully match sequences of words. Even providing a password, or text key will only work if there are no ties.
@ budman85: For practical real world purposes you are correct but since this is an exam and therefore a controlled environment we can assume that plainText.txt was provided and has no such issue. Always remember how much schools half-ass leason plans, especially for standardized tests.