# Crypto - Replacement

## [Full Implementation](https://github.com/kinasant/THR34DR1PP3R/blob/main/2024/WANICTF/cry-replacement/cry-replacement/replacement.ipynb)

## Challenge

```python
from secret import cal
import hashlib

enc = []
for char in cal:
    x = ord(char)
    x = hashlib.md5(str(x).encode()).hexdigest()
    enc.append(int(x, 16))
        
with open('my_diary_11_8_Wednesday.txt', 'w') as f:
    f.write(str(enc))

```

## Solution

Since the range is limited to ascii characters, we can map each individual hashed character to the encrpyted test and decode it

```python
m=[]
for i in range(256):
    m.append(int(hashlib.md5(str(i).encode()).hexdigest(),16))
for i in c:
    if i in m:
        print(chr(m.index(i)),end="")
#FLAG{13epl4cem3nt}
```
