2 days ago I just smashing my keyboard, but suddenly my friend Dorateatcheese, sending weird message.
No one know what he saying.
Until Jan 18th 2023, Dorateatcheese said in Zalo: You will never decode my message
, this challenge me.
I tried CyberChef, but... doesn't detect anything.
To find it, we need to know the magic.
I'll take Uryyb thlf jung'f hc?
as example.
- First, find the magic. I found the word
jung'f
look familiar tothat's
orwhat's
- Second, see the range of each word in ASCII Table.
I take the range of
j
witht
andw
| j | 106 + 10 = 116 | t |
| j | 106 + 13 = 119 | w |
Next, take the range of u
with h
| u | 117 - 13 = 104 | h |
And continue, we have:
| j | 106 + 13 = 119 | w |
| u | 117 - 13 = 104 | h |
| n | 110 - 13 = 97 | a |
| g | 103 + 13 = 110 | t |
| ' | N O T U S E D | ' | if this is space or not a char, don't.
| f | 102 + 13 = 115 | s |
This have a lot of number 13
(i hate that number), so the offset is +13
and -13
- Third, I try with other character, however...
If we take
z
for example, the ASCII code is122
, if we using+13
this will go to other one.
So, we have to use -13
instead.
- Note: If UPPERCASE CHAR, the range must be
65 (A)
to90 (Z)
. if lowercase char, the range must be97 (a)
to122 (z)
. Or else it won't be working. I fully solved in Notepad (i wanted to do it on Excel, but lazy).
Later I coded C++ code to solve the Dorateatcheese puzzle. You can check here.
Since i'm too lazy to do it by hand, I've to do it in C++
// offset is int.
if(s[i] >= 'a' && s[i] <='z' || s[i] >= 'A' && s[i] <='Z'){
if(s[i] + offset >= 'a' && s[i] + offset <='z' || s[i] + offset >= 'A' && s[i] + offset <='Z')
cout<<char(s[i] + offset);
else if (s[i] - offset >= 'a' && s[i] - offset <='z' || s[i] - offset >= 'A' && s[i] - offset <='Z')
cout<<char(s[i] - offset);
}
However, when I run it, this will fail on second rule:
- If UPPERCASE CHAR, the range must be
65 (A)
to90 (Z)
. if lowercase char, the range must be97 (a)
to122 (z)
. Or else it won't be working. So, I recode it.
for(int i=0; i<=s.size(); i++){
if(s[i] >= 'a' && s[i] <='z'){
if(s[i] + offset >= 'a' && s[i] + offset <='z')
cout<<char(s[i] + offset);
else if (s[i] - offset >= 'a' && s[i] - offset <='z')
cout<<char(s[i] - offset);
}
else if (s[i] >= 'A' && s[i] <='Z'){
if(s[i] + offset >= 'A' && s[i] + offset <='Z')
cout<<char(s[i] + offset);
else if (s[i] - offset >= 'A' && s[i] - offset <='Z')
cout<<char(s[i] - offset);
}
else if (s[i] == ' ') cout<<" ";
else cout<<s[i];
}
What this thing do?
if(s[i] >= 'a' && s[i] <='z'){
}
else if (s[i] >= 'A' && s[i] <='Z'){
}
- If the current
i
is valid lowercase char or UPPERCASE CHAR, we do something.
if(s[i] + offset >= 'a' && s[i] + offset <='z')
cout<<char(s[i] + offset);
else if (s[i] - offset >= 'a' && s[i] - offset <='z')
cout<<char(s[i] - offset);
- This is for lowercase char
- If we take current character plus the number (offset) we shift is valid char, we print out.
- Else if we take current character minus the number (offset) we shift is valid char, we print out.
if(s[i] + offset >= 'a' && s[i] + offset <='z')
cout<<char(s[i] + offset);
else if (s[i] - offset >= 'a' && s[i] - offset <='z')
cout<<char(s[i] - offset);
- Same thing as lowercase char, but this is for UPPERCASE CHAR
else if (s[i] == ' ') cout<<" ";
else cout<<s[i];
- If it have space
- Else we print something else (like
@
)
- After done a while, I already have nightmare on number 13.
- When I played CyberChef a while, I found out ROT13. I was thinking:
oh man not number 13...
, I drag it and...
- So, that entire time, Dorateatcheese USING ROT13?????
- Oh well, this is worth a try.