Created
January 9, 2018 10:11
-
-
Save l4ci/de3c8bb270cfabc4c0d6b0472ce6fa3a to your computer and use it in GitHub Desktop.
Encrypts an email via rot13 encryption
This file contains hidden or 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
| <?php | |
| /** | |
| * Encrypts an email w/out mailto link via rot13 encryption | |
| * decrypts it via javascript | |
| * @param string $email Email | |
| * @param boolean $mailto Wrap in <a href='mailto:'></a> | |
| * @return string Safe Email | |
| */ | |
| function safeMail($email,$mailto=true){ | |
| $e = str_rot13($email); | |
| if ($mailto){ | |
| return '<script type="text/javascript"> | |
| document.write(\'<n uers="znvygb:'.$e.'">'.$e.'</n>\'.replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);})); | |
| </script>'; | |
| }else{ | |
| return '<script type="text/javascript"> | |
| document.write(\''.$e.'\'.replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);})); | |
| </script>'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment