rumd3x/php-brainfuck

A nice PHP Utility made out of boredom for encoding a string into brainfuck code and vice-versa.

1.1.0 2023-12-24 23:33 UTC

This package is auto-updated.

Last update: 2024-04-25 00:25:01 UTC


README

A nice PHP Utility made out of boredom for encoding a string into brainfuck code and vice-versa.

Installation

To install via composer just run

  composer require rumd3x/php-brainfuck

Usage

Encoding

use Rumd3x\Brainfuck\Brainfuck;

echo Brainfuck::encode("Hello World!"); 
// outputs: ++++++++++[>+++++++>++++++++++>+++++++++++>+++++++++++>+++++++++++>+++>+++++++++>+++++++++++>+++++++++++>+++++++++++>++++++++++>+++<<<<<<<<<<<<-]>++.>+.>--.>--.>+.>++.>---.>+.>++++.>--.>.>+++.

There's also a second a third optional parameters for the encoding.

The second is for replacing non-ASCII characters.

And the third is for generating an minified or pretty-printed version of the code.

use Rumd3x\Brainfuck\Brainfuck;

echo Brainfuck::encode("Some ASCII: ABC+ŤĎ and some non-ASCII: Ąąśćł.'", true); // will replace non-ascii with their ascii counterpart 
echo Brainfuck::encode("Prettifying'", false, true); // will output pretty printed brainfuck code

Decoding

use Rumd3x\Brainfuck\Brainfuck;

echo Brainfuck::decode("++++++++++[>+++++++>++++++++++>+++++++++++>+++++++++++>+++++++++++>+++>+++++++++>+++++++++++>+++++++++++>+++++++++++>++++++++++>+++<<<<<<<<<<<<-]>++.>+.>--.>--.>+.>++.>---.>+.>++++.>--.>.>+++."); 
// outputs: Hello World!

Happy brainfucking!