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:
- Make an issue.
- Fork the repo.
- Make your changes.
- 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.