Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Forked from andrewmd5/README.md
Last active May 31, 2023 06:48
Show Gist options
  • Save Beyarz/f70644af410db3c456d5eec12bf4982d to your computer and use it in GitHub Desktop.
Save Beyarz/f70644af410db3c456d5eec12bf4982d to your computer and use it in GitHub Desktop.
Decipher this text - solution

Decipher this text

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
# frozen_string_literal: true
def cipher(indata)
string_builder = ""
encoded_string_builder = ""
encoder = "meatball"
i = 0
for letter in indata.chars
if (letter.ord >= 65 && letter.ord <= 90) || (letter.ord >= 97 && letter.ord <= 122)
string_builder += letter.unpack("B8").join("")
else
string_builder += letter
end
end
for char in string_builder.chars
if char == "1"
encoded_string_builder += encoder[i].capitalize
i += 1
elsif char == "0"
encoded_string_builder += encoder[i]
i += 1
else
encoded_string_builder += char
end
if i >= encoder.chars.count
i = 0
end
end
encoded_string_builder
end
indata = "Wow, [REDACTED]"
puts cipher(indata)
# => "mEaTbALLmEAtBALLmEATbALL, mEATBalLmEAtBALLmEATbAlL mEAtbalLmEATbaLlmEAtbAlL mEATbaLLmEATbAlLmEATballmEAtbAlLmEATbaLl mEATbaLLmEAtBAlLmEAtbalLmEATbaLlmEATbAll! mEaTbALLmEAtbalLmEAtBALlmEATbAll mEAtbalL mEAtBaLlmEAtBALLmEAtbaLl? mEaTbALLmEAtbAlL'mEATbaLlmEAtbAlL mEAtBallmEAtBalLmEATbaLlmEAtBalLmEAtBALlmEAtbALL: mEAtbalLmEAtBALlmEAtbAllmEATbaLlmEAtbAlLmEATbALL@mEAtbaLlmEAtbAlLmEATbAllmEATbALLmEAtBalLmEATBallmEATbAllmEAtBAllmEAtbalLmEAtbaLlmEATbaLL.mEAtbaLLmEAtBALLmEAtBAlL"
# frozen_string_literal: true
def decipher(indata)
string_builder = ""
temp_string = ""
for letter in indata.chars
if (letter.ord >= 65 && letter.ord <= 90)
temp_string += "1"
elsif (letter.ord >= 97 && letter.ord <= 122)
temp_string += "0"
else
string_builder += letter
end
if temp_string.chars.count >= 8
string_builder += temp_string.to_i(2).chr
temp_string = ""
end
end
string_builder
end
indata = "mEaTbALLmEAtBALLmEATbALL, mEATBalLmEAtBALLmEATbAlL mEAtbalLmEATbaLlmEAtbAlL mEATbaLLmEATbAlLmEATballmEAtbAlLmEATbaLl mEATbaLLmEAtBAlLmEAtbalLmEATbaLlmEATbAll! mEaTbALLmEAtbalLmEAtBALlmEATbAll mEAtbalL mEAtBaLlmEAtBALLmEAtbaLl? mEaTbALLmEAtbAlL'mEATbaLlmEAtbAlL mEAtBallmEAtBalLmEATbaLlmEAtBalLmEAtBALlmEAtbALL: mEAtbalLmEAtBALlmEAtbAllmEATbaLlmEAtbAlLmEATbALL@mEAtbaLlmEAtbAlLmEATbAllmEATbALLmEAtBalLmEATBallmEATbAllmEAtBAllmEAtbalLmEAtbaLlmEATbaLL.mEAtbaLLmEAtBALLmEAtBAlL"
puts decipher(indata)
# => "Wow, [REDACTED]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment