GithubHelp home page GithubHelp logo

email-obfuscator's Introduction

Email Obfuscator

A text filter for automatic email obfuscation using the well-established Javascript and a CSS fallback:

  • For Javascript-enabled browsers: ROT13 ciphering
  • For non-Javascript browsers: CSS reversed text direction

Contents

Installation & usage

Common installation step

Add the library to composer.json:

"require": {
    "propaganistas/email-obfuscator": "~1.0",
}

And finally include the supplied Javascript file (assets/EmailObfuscator.js) somewhere in your template. Publish the file yourself or use the following CDN link (no uptime guaranteed):

https://cdn.rawgit.com/Propaganistas/Email-Obfuscator/master/assets/EmailObfuscator.js

Additional Platform specific steps

Standalone

Include the src/Obfuscator.php file somewhere in your project:

require_once 'PATH_TO_LIBRARY/src/Obfuscator.php';

Parse and obfuscate a string by using the obfuscateEmail($string) function.

Laravel 5

You have 3 options depending on your use case:

  • (recommended) If you want to obfuscate all email addresses that Laravel ever outputs, add the Middleware class to the $middleware array in App\Http\Middleware\Kernel.php:

    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    	    ...
    	\Propaganistas\EmailObfuscator\Laravel\Middleware::class,
    ];
  • If you only want to have specific controller methods return obfuscated email addresses, add the Middleware class to the $routeMiddleware array in App\Http\Middleware\Kernel.php:

    protected $routeMiddleware = [
    	'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    	...
    	'obfuscate' => \Propaganistas\EmailObfuscator\Laravel\Middleware::class,
    ];

    and apply controller middleware as usual in a controller's construct method or route definition:

    public function __construct()
    {
        $this->middleware('obfuscate');
    }
    ```
  • If you want to apply obfuscation only on specific strings, just use the obfuscateEmail($string) function.

Twig

Add the extension to the Twig_Environment:

$twig = new Twig_Environment(...);
$twig->addExtension(new \Propaganistas\EmailObfuscator\Twig\Extension());

The extension exposes an obfuscateEmail Twig filter, which can be applied to any string.

{{ "Lorem Ipsum"|obfuscateEmail }}
{{ variable|obfuscateEmail }}

Your platform not listed here? (aka "Go go community!")

Well, feel free to hop in and create an integration yourself! If you have made an integration bundle/extension/package for a specific framework or CMS, please:

  • Fork the project
  • Place the necessary files in a correspondingly named folder in src/
  • Supply a README entry
  • Open up a pull request

If your platform enforces a strict package structure, create a repository and submit a pull request supplying only a README entry pointing to your repository.

Credits

email-obfuscator's People

Contributors

tanerkay avatar

Watchers

 avatar  avatar

Forkers

epidoux

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.