Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

joahg/obfuscatejs

Repository files navigation

#obfuscatejs Gem Version Build Status

Rails gem for backend string obfuscation. Obfuscate any string using the simple obfuscate view helper in Rails.

##Installation

To use Obfuscatejs in your project, simply add it to your Gemfile:

	gem 'obfuscatejs'

and add Obfuscatejs to your app/assets/javascripts/application.js:

	//= require obfuscatejs 

##Usage

To use in a view:

	<%= obfuscate 'hello world' %>

Obfuscatejs obfuscates strings using Hex encryption so webcrawlers are unable to recognize the text.

Obfuscatejs also makes special provisions for email addresses. Use the obfuscate_email helper to automatically generate a <a href='mailto:your_email'>your_email</a> in your view. Usage is as follows:

	<%= obfuscate_email '[email protected]' %>
	# Outputs <a href='mailto:[email protected]'>[email protected]</a>

You are also able to provide a custom message in lieu of the email being the link text:

	<%= obfuscate_email '[email protected]', 'email me' %>
	# Outputs <a href='mailto:[email protected]'>email me</a>

Obfuscatejs also has support for subject and body fields in an email link:

	<%= obfuscate_email '[email protected]', 'email me', 'my subject' %>
	# Outputs <a href="mailto:[email protected]?subject=my%20subject">email me</a>

	<%= obfuscate_email '[email protected]', 'email me', 'my subject', 'my body' %>
	# Outputs <a href="mailto:[email protected]?subject=my%20subject&body=my%20body">email me</a>

	<%= obfuscate_email '[email protected]', 'email me', '', 'my body' %>
	# Outputs <a href="mailto:[email protected]?body=my%20body">email me</a>

##How it works

Obfuscatejs translates your text to Hex in the backend, then puts a <span data-obfuscated='hex_encrypted_text'></span> in your view. Obfuscatejs then runs a frontend script to translate that encrypted text to readable text only visible by human clients, and not spam bots.

##Contributing

If you find a bug, or would like to help out with development, just follow some simple steps:

  1. Make an issue.
  2. Fork the repo.
  3. Make your changes.
  4. Commit and create a pull request.

##Author

Obfuscatejs is written and maintained by Joah Gerstenberg, copyright 2014. All code contained within these files are licensed under an MIT license.

Bitdeli Badge

About

Rails gem for backend string obfuscation in views.

Resources

License

Stars

Watchers

Forks

Packages

No packages published