LENcrypt

We modified the encryption algorithm so it will work despite losing the password… Probably.

Files given:

The encryption method is pretty simple, convert the plaintext to a number \(pt\), find the length \(\ell\) of the file, compute the ciphertext \(ct=pt\cdot\ell\) and save this as the encrypted file.

Notice that file length, as a mathmatical function, is simply \(\left\lceil\log_{256}\cdot\right\rceil\), and since \(\log(ab)=\log(a)+\log(b)\), if \(a=pt\) and \(b=\ell=\left\lceil\log_{256}\cdot\right\rceil\), the file size of the encrypted file, being \(\log_{256}(ab)\), is almost the same as the plaintext file as \(\log_{256}\log_{256}(a)\) is a very small number.

We can numerically approximate the length of the file with your favourite numerical root finding algorithm, for instance Newton-Raphson to roughly \(\ell\) an just brute force values near it and check if \(ct\) is divisible by \(\ell\), if it is, then compute \(pt=\frac{ct}\ell\) and save it. With this, we get the flag:

flag picture

The script to get the flag can be found at solve.sage

Flag: WH2021{LencRypTi0n}