Skip to content

Instantly share code, notes, and snippets.

@andrewmd5
Last active May 30, 2023 19:57
Show Gist options
  • Save andrewmd5/c0ed252a35645e39ec498259beadf3ce to your computer and use it in GitHub Desktop.
Save andrewmd5/c0ed252a35645e39ec498259beadf3ce to your computer and use it in GitHub Desktop.
decipher this text, get $100

Can you crack the secret message hidden within this cipher? I've taken a phrase and encoded it into a string of words that look like "meatball". It's a bit tricky, but I believe in your skills!

Cipher Text:

mEaTbALLmEAtBALLmEATbALL, mEATBalLmEAtBALLmEATbAlL mEAtbalLmEATbaLlmEAtbAlL mEATbaLLmEATbAlLmEATballmEAtbAlLmEATbaLl mEATbaLLmEAtBAlLmEAtbalLmEATbaLlmEATbAll! mEaTbALLmEAtbalLmEAtBALlmEATbAll mEAtbalL mEAtBaLlmEAtBALLmEAtbaLl? mEaTbALLmEAtbAlL'mEATbaLlmEAtbAlL mEAtBallmEAtBalLmEATbaLlmEAtBalLmEAtBALlmEAtbALL: mEAtbalLmEAtBALlmEAtbAllmEATbaLlmEAtbAlLmEATbALL@mEAtbaLlmEAtbAlLmEATbAllmEATbALLmEAtBalLmEATBallmEATbAllmEAtBAllmEAtbalLmEAtbaLlmEATbaLL.mEAtbaLLmEAtBALLmEAtBAlL

Prize

  • The first individual to crack the cipher and reveal the original message will win the $100!
  • Everyone who cracks it is eligible for the grand prize.

How to Participate

  1. Read the cipher text above.
  2. Put on your thinking cap and try to decipher the hidden message.
  3. Once you think you've cracked it, send me a direct message with your solution (the code and the deciphered text) @andrewmd5 on Twitter

Good luck and happy deciphering!

@andrewmd5
Copy link
Author

thank you to everyone who submitted a solution. I'll be in touch.

Here was the answer:

/**
 * Decrypts a given string.
 * Each version of the word "meatball" is converted back to the original character it represents,
 * where each letter's casing represents a bit in the binary form of the ASCII code of the character.
 * @param text The string to be decrypted.
 * @returns The decrypted string.
 */
const decrypt = (text: string): string => {
    let result = '';
    let i = 0;

    // Iterate over the encrypted string.
    while (i < text.length) {
        // Get the ASCII code of the character.
        let asciiCode = text[i].charCodeAt(0);

        // If the character is not part of the encrypted alphabet, add it to the result as is and move the pointer.
        if (asciiCode < 65 || (asciiCode > 90 && asciiCode < 97) || asciiCode > 122) {
            result += text[i];
            i++;
            continue;
        }

        // Take the next 8 characters to form a chunk.
        let chunk = text.substring(i, i + 8);
        let binary = '';

        // For each character in the chunk, convert it back to binary.
        // Uppercase characters represent 1 and lowercase characters represent 0.
        for (let bit of chunk) {
            binary += bit === bit.toUpperCase() ? '1' : '0';
        }

        // Convert the binary back to ASCII and add the character to the result.
        result += String.fromCharCode(parseInt(binary, 2));

        // Move the pointer by 8 to the next chunk.
        i += 8;
    }

    // Return the final decrypted string.
    return result;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment