Package Exports
- email-scramble
- email-scramble/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (email-scramble) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
email-scramble
Encode/decode email addresses and phone numbers with ROT-18 to hide them from bots. Can be used server-side with Node.js or in a browser.
If you'd like to know more about obfuscation techniques and their success ratio, here is a great blog post on the subject.
Getting Started
email-scramble uses a simple ROT transformation. The default rotation is ROT-18: letters will be rotated by 13 and numbers by 5.
var encodedEmail = emailScramble.encode("mail@example.com");
var decodedMail = emailScramble.decode(encodedMail);
// You can also pick any other flavor of ROT:
function myROT(str) {
// Here letters are obfuscated with ROT-13 and numbers are kept clear.
return emailScramble.rot(13, 0, str);
}
// Functional-programming partial application style:
var myRot = emailScramble.rot.bind(emailScramble, 13, 0);Here is a real-world example:
// <a href="znvygb:znvy@rknzcyr.pbz" data-email-scramble>Send me an email!</a>
var links = document.querySelectorAll("[data-email-scramble]");
links.forEach(function decodeLink(link) {
link.href = emailScramble.decode(link.href);
});Download & import
npm install --save email-scramble// ES6+
import emailScramble from "email-scramble";
// The CommonJS way.
var emailScramble = require("email-scramble");