# Cryptography challenges in HSCTF 10

## double-trouble

There was a given pdf file with the challenge.

Thanks to the hint, it is caesar cipher.

So decrypting the small part.

Flag: `flag{CaesarCiphersAreCool}`

## really-small-algorithm

Putting the numbers into a decoder gives flag.

Flag: `flag{bigger_is_better}`

## cupcakes

I tried vigenere cipher which needed a key.

Flag: `flag{instantbatter}`

## trios

Error in data.txt as it is not a multiple of 3:

```
IIqrBRz → IqrBrz
S4mLtKOIqr2stRbcQHJAPR2svphjHu0 → 4mLtKOIqr2stRbcQHJAPR2svphjHu0
```

Looks like a substitution cipher but each letter is represented by a random group of 3 characters. So, just assign each group of 3 into a letter and use quipqiup.

```
g = ""
bad = ",.\n {}"
with open("data.txt", "r") as f:
for c in f.read():
if c not in bad:
g += c
abc = [chr(i) for i in range(97, 123)]
g = [g[i:i+3] for i in range(0, len(g), 3)]
# split into groups of 3
found = []
s = ""
i = 0
for k in g:
if k not in found:
found.append(k)
s += abc[i]
i += 1
else:
d = found.index(k)
s += abc[d]
# assign 1 letter for each group
print(s)
>>> "abcdebefgchijhekclijmjbnechehoplfieqremmcdesakethjksimbchducdesmijashqcqsaaepehifbcshievijaigemcrebchducdebjhdehjudgijasbbjhemgeeijpmjchqigehkeojuhiigejoouppehoemjaecogbeiiepimsbbedcbijjkhwumijhedushecfsdshksixepbchq"
```

Flag:`flag{elephant}`