This article is based on this one and the latest version of plugin. Now you can easily encrypt your links without changing plugin code.

1) Ensure that you have php-mcrypt installed:

For CentOS, type

sudo yum install php-mcrypt

For ubuntu, type

sudo apt-get install php5-mcrypt

For windows, enable this extension in php.ini:

extension=php_mcrypt.dll

2) Create file wp-content/uploads/custom-parser.php and add here the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
if(!defined('DB_NAME'))
  die('Error: Plugin "wp-noexternallinks" does not support standalone calls, damned hacker.');
 
#include base parser
include_once(ABSPATH . 'wp-content/plugins/wp-noexternallinks/wp-noexternallinks-parser.php');
 
class custom_parser extends wp_noexternallinks_parser
{
  var $salt,$iv;
  function init_crypt()
  {
    if(!function_exists('mcrypt_create_iv'))
      die('php-mcrypt library not installed, can not process links!');
    $this->salt ='ms8-sRt-kBs5-s1wQ';
    $this->iv=mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
  }
  function encode_link($url)
  {
    if(!$this->salt)
      $this->init_crypt();
    return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->salt, $url, MCRYPT_MODE_ECB, $this->iv)));
  }
  function decode_link($url)
  { 
    if(!$this->salt)
      $this->init_crypt();
    return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->salt, base64_decode($url), MCRYPT_MODE_ECB, $this->iv));
  }
}
?>

Do not forget to change $salt to any custom value! Also, add statistic handling from the original function if you use statistics.