Challenge 7 Solution
Quote:
Originally Posted by Village Idiot
Are you sure you encoded it right? It comes out as gibberish when converted to ascii or anything else.
|
Absolutely sure that it was encoded right. The hint (Base64) should've given a clue but I guess the string was not particularly clear once you had used
base64_decode on it.
Here's a step-by-step that I just took because I had actually forgotten the original encoding method.
1. base64_decode the string. This gives the message
Q-: 7 rtaryynup gnro V
Now here's the crunch, that initial set of three characters looks kind of like a smiley face (which usually comes at the end of a phrase) and the only capital letter (not in the smiley) is at the end of the message (yet capitals usually come at the beginning). So, reverse the message!
2. Use strrev to see what the message says in reverse, giving
V orng punyyratr 7 :-Q. Ok, well if that's a sentence then it is gobbledygook (nonsense)! So it has a structure like a sentence but the letters are all messed up (but the non-letter smiley characters are ok, and 7 is the number of this challenge). So what mixes up letters yet leaves other characters intact... str_rot13!
3. Use str_rot13 on the message, to give
I beat challenge 7 :-D
Aha, the message in all it's glory!
So the solution, would be very simply (though obviously arriving at that solution wasn't simple!):
PHP Code:
function challenge7($message) {
return str_rot13(strrev(base64_decode($message)));
}
ob_start('challenge7');
// Hint: Base 64
echo '
============
US 06ID cgcn
R hcnl5bn Vw
IGdu cm8 gVg
============
';
ob_end_flush();
Phew
