#C9710. Secure Message with XOR Encryption and Digital Signature
Secure Message with XOR Encryption and Digital Signature
Secure Message with XOR Encryption and Digital Signature
You are given a plaintext message and a secret key. Your task is to encrypt the message using an XOR cipher and then generate a digital signature by reversing the encrypted message. Finally, output the concatenation of the encrypted message and its signature.
Let \( M \) be the input message and \( K \) be the secret key. The encryption is defined as follows:
[ E_i = M_i \oplus K_{(i \mod |K|)} \quad \text{for } i = 0, 1, \ldots, |M|-1 ]
The signature is the reverse of the encrypted message:
[ S = \text{reverse}(E) ]
The final output is \( E + S \), the concatenation of the encrypted message and its signature.
inputFormat
The input is provided via stdin and consists of two lines:
- The first line contains the plaintext message \( M \) (a non-empty string).
- The second line contains the key \( K \) used for encryption (a non-empty string).
outputFormat
Output to stdout the concatenation of the encrypted message and its digital signature. The encryption is performed using an XOR operation and the signature is the reversal of the encrypted message.
## samplehello
secret
\u001b\u0000\u000f\u001e\n\n\u001e\u000f\u0000\u001b