PurrCrypt is a playful Python module that encodes text into a cat‑like language using only the characters R and r (prefixed by Pu).
It provides two modes:
- Simple encoding/decoding – direct mapping of bits to
R(1) andr(0). - Key‑based encryption/decryption – each bit is randomly flipped based on a seed, making the output reversible only with the correct key.
Converts the given text into a Pu... string by replacing each 1 bit with R and each 0 bit with r.
Multiple arguments are joined with spaces.
Reverses purr_encode. Expects a string starting with Pu followed only by R/r.
Raises ValueError for invalid input.
Similar to purr_encode, but uses the given key to seed Python’s random generator.
For every bit:
- If the original bit is
1, a random choice decides whether to outputRorr. - If the original bit is
0, the opposite random mapping is applied.
This makes the output unpredictable without the key.
Reverses purr_encrypt using the same key.
It reads the R/r sequence and, based on the same random decisions, reconstructs the original bits.
>>> import PurrCrypt
>>> encoded = PurrCrypt.purr_encode("Meow")
>>> print(encoded)
PuRrRrRrrRrRRrRrRrRrRrRrrRrrRrRRrRrrRrRrRr
>>> decoded = PurrCrypt.purr_decode(encoded)
>>> print(decoded)
Meow
>>> encrypted = PurrCrypt.purr_encrypt("Hello", key=123)
>>> print(encrypted)
PuRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRr
>>> decrypted = PurrCrypt.purr_decrypt(encrypted, key=123)
>>> print(decrypted)
Hello- The encoding/decoding functions are deterministic and always produce the same output for a given input.
- The encryption/decryption functions use
random.seed(key)andround(random())to generate a deterministic but pseudo‑random bit flip.
The same key must be used for both encryption and decryption. - Only characters
Randrare allowed after the initialPu. Any other character raises aValueError. - The module works with any UTF‑8 text.
PurrCrypt — это игровой модуль на Python, который преобразует текст в «кошачий» язык, используя только символы R и r (с префиксом Pu).
Предусмотрено два режима:
- Простое кодирование/декодирование – прямая замена битов:
1→R,0→r. - Шифрование/дешифрование с ключом – каждый бит случайно инвертируется в зависимости от seed’а, что делает результат обратимым только при наличии правильного ключа.
Преобразует переданный текст в строку вида Pu..., заменяя каждый бит 1 на R, а 0 на r.
Несколько аргументов объединяются через пробел.
Выполняет обратное преобразование для purr_encode. Ожидает строку, начинающуюся с Pu, за которой следуют только символы R/r.
При неверном формате возбуждает исключение ValueError.
Работает аналогично purr_encode, но использует переданный key для инициализации генератора случайных чисел.
Для каждого бита:
- Если исходный бит равен
1, случайным образом выбирается, вывестиRилиr. - Если исходный бит равен
0, применяется противоположное случайное отображение.
Без знания ключа восстановить исходный текст практически невозможно.
Восстанавливает текст, зашифрованный с помощью purr_encrypt с тем же ключом.
Анализирует последовательность R/r и, используя ту же последовательность случайных решений, воссоздаёт исходные биты.
>>> import PurrCrypt
>>> encoded = PurrCrypt.purr_encode("Мяу")
>>> print(encoded)
PuRrRrRrrRrRRrRrRrRrRrRrrRrrRrRRrRrrRrRrRr
>>> decoded = PurrCrypt.purr_decode(encoded)
>>> print(decoded)
Мяу
>>> encrypted = PurrCrypt.purr_encrypt("Привет", key=123)
>>> print(encrypted)
PuRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRr
>>> decrypted = PurrCrypt.purr_decrypt(encrypted, key=123)
>>> print(decrypted)
Привет- Функции простого кодирования/декодирования детерминированы и всегда дают одинаковый результат для одних и тех же входных данных.
- Функции шифрования/дешифрования используют
random.seed(key)иround(random())для создания детерминированного псевдослучайного потока.
Один и тот же ключ должен применяться как при шифровании, так и при дешифровании. - После начального
Puдопускаются только символыRиr. Любой другой символ вызывает исключениеValueError. - Модуль работает с любым текстом в кодировке UTF‑8.
Этот проект распространяется под лицензией MIT. Подробности см. в файле LICENSE.