Created
September 27, 2012 18:30
-
-
Save KZeni/3795580 to your computer and use it in GitHub Desktop.
Standalone / On-demand MailHide Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// On-demand MailHide function (give it a raw email & it returns the raw MailHide url) | |
// *Useful when added to a WordPress theme's functions.php file if you need to mailhide an email anywhere | |
// *Usage: <a href="<?php echo mailhide_this('kurt@kzeni.com'); ?>" target="_blank" title="Reveal email address">Send me an email</a> | |
function mailhide_this($email){ | |
$pubkey = '01aIqfsfCm4RVQsVt7lx95tA=='; | |
$privkey = '228ff0e136ae39a0c7bc22ab595667b9'; | |
$ky = pack('H*', $privkey); | |
$mode = MCRYPT_MODE_CBC; | |
$enc = MCRYPT_RIJNDAEL_128; | |
$block_size = 16; | |
$numpad = $block_size-(strlen($email)%$block_size); | |
$email = str_pad($email, strlen($email)+$numpad, chr($numpad)); | |
$cryptmail = mcrypt_encrypt($enc, $ky, $email, $mode, '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'); | |
$url = 'http://www.google.com/recaptcha/mailhide/d?k='.$pubkey.'&c='.strtr(base64_encode($cryptmail),'+/','-_'); | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment