Cipher rewritten (without Cython now)