Reputation: 2959
Here's an example for better understanding of the question:
2.0.0-p353 :003 > puts Base64.decode64 content
Glad to see we managed to get your attention!
You'll find our message in the bottle. Choose one or more tools to open it;
drop me a mail if you're interested in working together.
$!'<
]!N3
!9<Z]NWl!Z]N
Q!]90!NW
<6<K$E
!'$*B0
K-!N3!
QW0o<!
f$Z!fW
<]]0K!<K!Q
l]9NK!`Z<K6!-?$K6N
!Z]NQ!f0!Z]<EE!`Z0!]90
H!$!EN]!Z]NQ!$--!]90!fNW
-!Z<EElf$EBZ!]N!]90!Z`'?
0*]!E<K0!N3!lN`W!W0ZQNKZ
0!3`EEZ]NQg1"LO^"OLFm"a[
1"@%d%[+X=R^"(a^"+OIR=F1
"IOX1"F%L7a%71["^O"=^"F=
C1":%j1"1FI"+O4411[+X=R^
"^mR1[+X=R^"[^OR"%.."^:1
"R:X%[1"RmX%I=.O4.OOI"^O
"^:1"[a(@1+^"F=L1"O4"mOa
X"X1[ROL[1"4aFF[^ORh2#&Y
2#JPe>M8#_P#&#\2Ye>,2#PY
>2M_2/#&Y,;>_2,_bY2#PM#&
#AeJ#)&\2/#\_&,D#b\>M8#\
PJ2#G>)Y&Y>2\#PS2M\PbY,2
/#)n#M2_5G>k#\_PS#&//#_;
2#hPY/#J>G&MP#_P#_;2#\b)
A2,_#G>M2#h;2M#\2M/>M8#b
\#&#J&>G#5bGG\_PS
CLUE #1
def decode_char(ch):
x = ord(ch) - 33
return None if (x % 3) else ' ' if x < 3 else chr(x / 3 + 64)
CLUE #2
function decodeChar(ch) {
var x = ch.charCodeAt(0) - 33
if (String.fromCharCode(x % 3 + 64) != 'A')
return null;
else if (x < 3)
return ' ';
else
return String.fromCharCode(x / 3 + 64)
}
CLUE #3
def decodeChar(c: Char): Option[Char] = c.toInt - 33 match {
case 2 => Some(' ')
case x if x % 3 > 1 => Some((x/3 + 64).toChar)
case _ => None
}
=> nil
The functions listed below the bottle do decode the bottle in a different ways. For example, JS code gives this:
"WE NOT ONLY USE JAVASCRIPT BUT COMPILE MORE LANGUAGES TO IT LIKE HAXE ELM COFFEESCRIPT TYPESCRIPT STOP ADD THE PHRASE PYRAMIDOFDOOM TO THE SUBJECT LINE OF YOUR RESPONSE FULL"
Other functions are giving different texts.
So the question here is: How to encrypt different texts in one "bottle" (encrypted text)?
Upvotes: 0
Views: 135
Reputation: 12620
Each character has a value encoded in it that denotes which algorithm is needed for decoding.
return None if (x % 3)
-> Anything not a multiple of 3 (n%3 != 0) is ignored.
if (String.fromCharCode(x % 3 + 64) != 'A') return null;
-> All characters not (n*3)+1, i.e. n%3 != 1, are ignored
if x % 3 > 1 => ...
-> only characters with (n%3) > 1, i.e. n%3 = 2, are decoded, others are ignored.
EDIT:
The encryption can be inferred as
c_output = ((c_input-64) * 3) + msg_no
where msg_no
is the number of the message (less than 3) the input character belongs to.
If you take a bigger number than 3 you can encode more different messages into the same stream. However, it is important that c_output
is still in the valid range for the datatype, e.g. a single ASCII character or byte. With 3 different message streams, encoding a µ
(code 181 in ASCII) is not possible: (181-64) * 3 > 255
. Equally, 9
(code 57 in ASCII) cannot be encoded because (57-64)*3 < 0
.
Upvotes: 1