joetannenbaum/obfuscate

Obfuscate strings in HTML using JavaScript (e.g. mailto links)

dev-master 2020-01-31 01:38 UTC

This package is auto-updated.

Last update: 2021-01-30 02:53:36 UTC


README

A quick-and-dirty library to obfuscate sensitive strings by dynamically creating special characters to print them out. Not foolproof by any means.

Installation

composer require joetannenbaum/obfuscate

Usage

use Obfuscate\Obfuscate;

require __DIR__ . '/vendor/autoload.php';

echo Obfuscate::str('this is a secret!');
echo Obfuscate::mailto('obfuscate@joe.codes');

...results in (different every time, still renders properly in HTML):

this is a secret!

<a href="&#x6d;&#x61;&#105;&#108;&#116;&#x6f;&#x3a;o&#x62;fu&#x73;&#x63;&#x61;t&#101;&#64;&#106;oe.co&#x64;&#101;s">o&#98;f&#x75;s&#99;&#97;t&#101;&#x40;&#x6a;&#x6f;e&#46;&#99;&#x6f;d&#x65;s</a>

Laravel

If you're using Laravel, this package automatically adds a Blade helper:

@obfuscate('this is a secret!')
@mailto('obfuscate@joe.codes')