dougallwinship / unicodez
unicodez library
Requires
- php: >=8.3
- ext-mbstring: *
- wp-cli/php-cli-tools: ^0.12.1
This package is auto-updated.
Last update: 2026-04-06 10:16:26 UTC
README
Encode/decode text to/from various Unicode character sets (ranges) using a seed for some reason ๐คท
For example "this is a test" encoded as Runic with a seed of 1 (using a pseudo shebang to integrate the seed number) gives: แก๏ปฟแแแแฐแกแแฎแ แแแกแแฎแ แแแแแแแแแแฉแฎแ แแ
...or "Why am I looking at this project? I probably need to rethink my priorities." encoded with Flags and a seed of 13 (without a pseudo-shebang) results in:
๐น๐ด๐ง๐ซ๐ฑ๐พ๐ฒ๐พ๐ฐ๐ฎ๐ฐ๐ฌ๐ธ๐ฎ๐ธ๐ง๐ฌ๐ฌ๐ต๐ช๐ฉ๐ช๐ฉ๐ช๐ธ๐ฎ๐ธ๐ง๐ฒ๐ผ๐พ๐ช๐ธ๐ฎ๐ธ๐ง๐ฆ๐ท๐ฌ๐ถ๐ฌ๐ท๐ง๐ง๐ฌ๐ท๐ง๐ง๐ธ๐ณ๐ฎ๐ฒ๐ฆ๐ฒ๐จ๐พ๐ง๐ท๐ฏ๐ช๐น๐ณ๐ต๐พ๐ธ๐ฎ๐ธ๐ง๐ฌ๐ฌ๐ต๐ช๐ฉ๐ฟ๐ฒ๐ผ๐ธ๐ฎ๐ธ๐ง๐ฉ๐ฟ๐ฒ๐ผ๐ฑ๐พ๐ฒ๐พ๐ฆ๐ฒ๐จ๐พ๐จ๐ฟ๐ธ๐ฐ๐ธ๐ฎ๐ธ๐ง๐ป๐ช๐ธ๐ณ๐ซ๐ท๐ฎ๐ฒ๐ฌ๐ท๐ง๐ง๐ฎ๐ถ๐ฌ๐ญ๐ง๐ผ๐ฒ๐จ๐ฌ๐ง๐ฒ๐ป๐ฉ๐ฟ๐ฒ๐ผ๐ธ๐ป๐ฉ๐ฏ๐ธ๐ฎ๐ธ๐ง๐ฒ๐ผ๐พ๐ช๐ธ๐ฎ๐ธ๐ง๐ป๐ช๐ธ๐ณ๐ซ๐ท๐ฎ๐ฒ๐ฌ๐ท๐ง๐ง๐ช๐ท๐ฌ๐ฉ๐ฌ๐ฌ๐ต๐ช๐ช๐ท๐ฌ๐ฉ๐ฆ๐ท๐ฌ๐ถ๐ฐ๐ฎ๐ฐ๐ฌ๐ธ๐ฎ๐ธ๐ง๐ง๐ท๐ฏ๐ช๐ง๐ผ๐ฒ๐จ๐ง๐ผ๐ฒ๐จ๐ฐ๐ฟ๐ง๐ฟ๐ธ๐ฎ๐ธ๐ง๐ฉ๐ฟ๐ฒ๐ผ๐ฌ๐ท๐ง๐ง๐ธ๐ฎ๐ธ๐ง๐ซ๐ท๐ฎ๐ฒ๐ง๐ผ๐ฒ๐จ๐ฉ๐ฟ๐ฒ๐ผ๐ฑ๐พ๐ฒ๐พ๐ฆ๐ฒ๐จ๐พ๐ง๐ท๐ฏ๐ช๐ธ๐ณ๐ฎ๐ฒ๐ธ๐ฎ๐ธ๐ง๐ฉ๐ช๐ฉ๐ช๐ฐ๐ฎ๐ฐ๐ฌ๐ธ๐ฎ๐ธ๐ง๐ป๐ช๐ธ๐ณ๐ซ๐ท๐ฎ๐ฒ๐ฆ๐ฒ๐จ๐พ๐ฌ๐ท๐ง๐ง๐ซ๐ท๐ฎ๐ฒ๐ฆ๐ฒ๐จ๐พ๐ฉ๐ฟ๐ฒ๐ผ๐ฆ๐ฒ๐จ๐พ๐ง๐ผ๐ฒ๐จ๐จ๐ฟ๐ธ๐ฐ๐ธ๐ท๐ต๐ฐ
IMPORTANT : Note that currently only 8-bit encoding is supported, which is sufficient to cover ASCII, but not much more!
Getting started:
The project uses composer to generate a PSR-4 autoloader, so to get started simply
composer install
There a single dependency on php-cli-tools.
Usage:
As indicated there are two types of encoding:
1. Using a pseudo-shebang
- this integrates the seed into the encoded text, meaning it can be decoded without knowing the seed.
- the pseudo-shebang indicates both the encoding range (set) and the seed used, a zero-width no-break space (U+FEFF) is used to delimit the pseudo-shebang.
- hence this technique cannot be used for obfuscation, and is essentially just for amusement!
- example:
$unicodez = new \Unicodez\ShebangUnicodez(); $encoded = $unicodez->encode("This is some text", \Unicodez\Mappings::TEXT_RUNIC, 123); $decoded = $unicodez->decode($encoded)
2. Using an explicit seed
- this means the seed must be known to decode the encoded text.
- hence this technique can be used for basic obfuscation.
- example:
$unicodez = new \Unicodez\SeedUnicodez(); $encoded = $unicodez->encode("This is some text", \Unicodez\Mappings::TEXT_RUNIC, 123); $decoded = $unicodez->decode($encoded, 123)
Tools/Examples
You can mount /public on a local webserver, or use the PHP webserver:
cd public
php -S localhost:8000
and look at:
- Shebang Encoder/Decoder translate to/from the shebang unicodez text
- Shebang Encode/Decode Test basic HTML test of each set using a shebang
- Shebang Autoload Test show unicodez shebang autoloading in practice
- Seed Encoder/Decoder translate to/from the seeded unicodez text
- Seed Encode/Decode Test basic HTML test of each set using a seed
- Seed Autoload Test show unicodez seed autoloading in practice
Include/Autoloader
Since this is implemented in PHP an include method and autoloader are also provided:
These both attempt to decode and evil eval the content.
Here is an example of using the shebang autoloader:
This attempts to add a reasonably sensible autoloader at the start of the PHP autoloader chain (using the prepend attribute), the hope is that you may be able to annoy/confound your colleagues/enemies by providing php implementations like the Runic autoload test script.
Obviously without a suitable plugin your IDE will be unable to assist with auto-completion etc...
Here is how to use the shebang include method:
$unicodez = new \Unicodez\ShebangUnicodez(); $unicodez->include("/src/Runic/SeedRunicTest");
Here is an example using the seeded autoloader.
Here is how to use the seed include method:
$unicodez = new \Unicodez\SeedUnicodez(); $unicodez->include("/src/Runic/SeedRunicTest", 1);
Note that in this case you must provide a seed for decoding, the mapping is determined automatically, but the seed can be kept secret in order to provide trivial obfuscation.
Command Line Tool
There is a command line tool which can be used to bulk encode/decode files.
Example of shebang encoding all files in a directory into Runic with prompts and backups:
./unicodez encode --target ~/Temp --flavour shebang --map Runic --seed 123 --write --verbose
Example of silently decoding all encoded files in a directory:
./uncodez decode --target ~/Temp --silent
The following commands are available:
- help
- version
- status
- encode
- decode
- cache-clear
PSR-12
The code largely conforms to the PSR-12 standard.
This is the tool that is used to check : https://github.com/PHPCSStandards/PHP_CodeSniffer/
Once installed and available globally (presumably via PATH settings), something like this can be used from the root dir:
phpcs --standard=PSR12 ./src/Unicodez/