HelloAdmin is 3 years old: a birthday greeting in code
Hi everyone! Today HelloAdmin turns three. To celebrate, here is a small trick for a birthday greeting that a developer, a system administrator or anybody else in IT will appreciate: a message that has to be decoded in the terminal before it can be read.
Problem: Ordinary birthday greetings are boring, and you want something a colleague in IT will actually smile at.
Solution: Turn the text into one big decimal number and send the number. The recipient decodes it with a one-line command in the terminal.
Step 1. The text
Write the greeting, for example:
Happy Birthday and many happy days in a new year of yours! ;)
Step 2. Text to hexadecimal
Every character is a byte, and every byte can be written as two hexadecimal digits. Any online converter does it, or the terminal:
printf 'Happy Birthday and many happy days in a new year of yours! ;)' | xxd -p | tr -d '\n'
The result:
486170707920426972746864617920616e64206d616e79206861707079206461797320696e2061206e65772079656172206f6620796f75727321203b29
Use printf, not echo: echo adds a line break at the end, which becomes an extra 0a in the hex string.
Step 3. Hexadecimal to one decimal number
Read the whole hex string as one number. Online converters can do it, or Python in the terminal:
python3 -c "print(int('486170707920426972746864617920616e64206d616e79206861707079206461797320696e2061206e65772079656172206f6620796f75727321203b29', 16))"
The number to send:
225954101606848758559958811116945025721722700479991025182955712534119300862609728341849169254783888232354129131748373390025977241003931812818336553
Step 4. Send it with a hint
Send the number together with the command that decodes it. The dc calculator, available on Linux and macOS, prints a number as the bytes it consists of when it is followed by P:
echo 225954101606848758559958811116945025721722700479991025182955712534119300862609728341849169254783888232354129131748373390025977241003931812818336553P | dc
The terminal answers with the greeting.
NOTE: The number is only a disguise, not encryption: anybody can decode it. For a longer message the number grows with the text (about 2.4 decimal digits per character), so keep the greeting short. Happy birthday to everybody who celebrates today, and thank you for three years with HelloAdmin!