> For the complete documentation index, see [llms.txt](https://fg0x0.gitbook.io/fg0x0s-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fg0x0.gitbook.io/fg0x0s-notes/ctf/other-ctf/asian-cyber-security-challenge/acsc-2023/merkle-hellman-cryptography.md).

# Merkle Hellman ( Cryptography )

We tired of RSA, try a new cryptosystem by merkle and hellman but we don't know how to decrypt the ciphertext.  We need your help for decrypt the ciphertext to get back my flag.txt!

{% file src="/files/vjt5SwZLhiZAA5qhwch8" %}
Source File
{% endfile %}

{% code title="merkle.py" overflow="wrap" lineNumbers="true" %}

```python
b = [7352, 2356, 7579, 19235, 1944, 14029, 1084]
c = [8436, 22465, 30044, 22465, 51635, 10380, 11879, 50551, 35250, 51223, 14931, 25048, 7352, 50551, 37606, 39550]
r = ''
for x in range(len(c)):
    for i in range(128):
        mask = f"{i:07b}"
        t = 0
        for j, bit in enumerate(mask):
            if bit == "1":
                t += b[j]
        if t == c[x]:
            r += chr(i)
print(r)
#  ACSC{E4zY_P3@zy}
```

{% endcode %}
