Want to try solving this problem? You can submit your code online if you log in or register.
Input File: secrtin.txt
Output File: secrtout.txt
Time Limit: 0.333 second
Encryption is the science of scrambling messages in order to hide information from prying eyes. As well as a long history in warfare, encryption is vitally important for commercial interests in a highly networked world. In this problem you will implement a simple, well known cipher (encryption algorithm).
Our cipher uses a keyword, which the parties wishing to communicate agree upon and keep secret. Letters of the keyword are used in order to scramble each letter of the message. If the message is longer than the keyword, as is usually the case, we start again at the beginning of the keyword.
To scramble a single letter of the message, the keyword letter is converted to a number where A = 1, B = 2, ..., Z = 26. The letter of the message is then advanced that number of letters in the alphabet. A letter which is advanced past Z returns to A.
For example, with the keyword ABC and the message WXYZ, we proceed as follows:
Hence the final, encrypted message is XZBA.
The first line of input shall consist of the keyword. The second line of input shall contain the message to encrypt.
Each line of input shall consist entirely of upper case alphabetic characters (i.e. A...Z). Each line of input shall consist of at least 1 and at most 50 characters.
Your program shall output a single line consisting of the encryption of the given message with the given keyword.
ETHAN THISISNOTMISSIONDIFFICULTMRHUNT
YBQTWXHWUANMAJCSXQGTNWCMHRLPVBY
JAMES THENAMEISBONDJAMESBOND
DIRSTWFVXUYOQOTWFFGHXE
For each test case, your program shall be awarded 100% of the marks if it outputs the correct encrypted message, and 0% otherwise.
Privacy
statement
© Australian Mathematics Trust 2001-2023
Page generated: 25 March 2023, 6:01pm AEDT