Protect Email Addresses Using ROT13 Substitution Cipher – email-protector.js

Category: Javascript | April 4, 2024
Views Total:14 views
Official Page:Go to website
Last Update:April 4, 2024


Protect Email Addresses Using ROT13 Substitution Cipher – email-protector.js


A powerful and user-friendly JavaScript solution to protect spambots from harvesting email addresses from your website.

The library encodes email addresses using ROT13 letter substitution cipher and automatically decodes them whenever the user clicks on the mailto link.

How to use it:

1. Download and import the email-protector.js into the page.

<script src="email-protector.js"></script>

2. Use the rot() function to encode an email address

// encoded with 13
let myEmail = EmailProtector.rot('[email protected]');
// encoded with 11
let myEmail = EmailProtector.rot('[email protected]', 11);
// encoded with 36
let myEmail = EmailProtector.rot('[email protected]', 36);

3. Insert the encoded email address into the page.

<span id="email-protector"></span>
// using append() method
EmailProtector.append('email-protector', myEmail);
// using write() method
// decoding with 15, because it was encoded with 11
EmailProtector.write('[email protected]', { code: 15 });
// or ...
  email:   '[email protected]',
  subject: 'Message from www',
  body:    'Hi, I\'m contacting you',
  cc:      '[email protected]',
  bcc:     '[email protected]'

4. You can also specify an email link label.

EmailProtector.append('email-protector', '[email protected]', { 
  linkLabel: 'email link label' 

5. Using global parameters and configuration.

EmailProtector.setGlobalParams({ email: '[email protected]', subject: 'Message from www' });
EmailProtector.setGlobalConfig({ code: 15, hiddenSpan: false, htmlComments: false });
// reset params and configs
EmailProtector.write('[email protected]');

6. All default parameters and configs for append() and write() functions

EmailProtector.write('[email protected]', {
  code: 13,
  cssReverse: true,
  hiddenSpan: true,
  htmlComments: true


v0.8.0 (04/04/2024)

  • Added support for complex email addresses.

v0.6.1 (03/27/2023)

  • Bugfix

v0.5.2 (05/21/2022)

  • Replaced deprecated String.prototype.substr() with substring()


  • Fixed bug with decoding a user name containing dots

You Might Be Interested In:

Leave a Reply