z-crack
Little Z likes decided to break his favourite encryption algorithm. He doesn't really know how it works, he just know that it applies some sort of encryption based on some key two times in a row.
The encryption is done using a key of N (1 <= N <= 7) hexadecimal digits.
Somehow, you found a program that will perform the encryption or decryption only once, and you want to help Little Z to find the key
InputThis is an interactive problem. From the first line of the standard input read an integer N. After that your program can communicate with the encryption algorithm in the following way:
- You can write: encrypt xxxx yyyy. where both xxxx and yyyy are hexadecimal strings (using lower case letters) of length N. In this case the algorithm will encrypt xxxx with the key yyyy and output the result as zzzz (also N) digits). You can read the result from the next line
- You can write: decrypt zzzz yyyy. Similar situation - the algorithm will decrypt zzzz and output xxxx that you can read from the next line.
- You can write: key yyyy saying that you have found the key. After this command your program should halt.
There is no limit on the number of times your program asks for encryption/decryption.
Using the key for encryption/decryption has to satisfy:
decrypt(decrypt(encrypt(encrypt(xxxx)))) == xxxx for all xxxx
Also, make sure you ALWAYS flush the output before waiting for feedback. After writing the string, use:
- You can write: encrypt xxxx yyyy. where both xxxx and yyyy are hexadecimal strings (using lower case letters) of length N. In this case the algorithm will encrypt xxxx with the key yyyy and output the result as zzzz (also N) digits). You can read the result from the next line
- You can write: decrypt zzzz yyyy. Similar situation - the algorithm will decrypt zzzz and output xxxx that you can read from the next line.
- You can write: key yyyy saying that you have found the key. After this command your program should halt.
There is no limit on the number of times your program asks for encryption/decryption.
Using the key for encryption/decryption has to satisfy:
decrypt(decrypt(encrypt(encrypt(xxxx)))) == xxxx for all xxxx
Also, make sure you ALWAYS flush the output before waiting for feedback. After writing the string, use:
cout.flush() in c++
fflush(stdout) in c
flush(output) in pascalYou read: 1
You write: encrypt 0 a
You read: b
You write: encrypt b a
You read: 8
You write: decrypt b a
You read: 0
You write: decrypt 8 a
You read: b
You write: key aSubmit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.