This message was edited by beetle17 at 2006-11-20 8:31:30
This message was edited by beetle17 at 2006-11-20 8:24:43
l just learn C program not long time ago,it is too diffcult for me to write a cipher
(Plaintext : a nice day)
(Key : -3)
(Ciphertext : X kfZb aXv)
Cipher will accept commands from the user and perform the operations required by the commands. There are three different commands. Key command starts with "K1:"followed by a string as the key. Encryption command starts with "E1:" followed by the plaintext. Decryption command starts with "D1:" followed by the ciphertext to be decrypted. After the user inputs an encryption (or decryption) command, Cipher1 should encrypt the plaintext (or decrypt the ciphertext) using the key input by a previous key command, and print the results. The error message "key not found" should be printed if the user inputs an encryption or decryption command before a key command. If the user
inputs multiple keys, the latest key will be used in the following encryption/decryption operations. Below are two examples (underlined text is the input from the user, and italic text is the output of Cipher).
When the plaintext/ciphertext includes non-letter symbols, Cipher1 will ignore them.For example, a plaintext of "No. 2" is equivalent to "No".
Example I of Cipher:
K 1: 3
E 1: I like dogs
C i p h e r t e x t is < L olnh grjv >
D 1: L olnh grjv
P l a i n t e x t i s < I like dogs >
E 1: H e l l o
C i p h e r t e x t i s < Khoor >
Example II of Cipher:
E 1: I like dogs
K e y not found
K 1: -54
E 1: Hello
C i p h e r t e x t is < Fcjjm>
K 1: h h h h
Invalid K e y