Publishing System Settings Logout Login Register
Simple String Encryption
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on May 13th, 2007
4204 views
PHP Coding
So, like most people that come to Pixel2Life I was browsing through the front page. Usually I check out either the PHP or Photoshop tutorials. Anyways, I came came across this little Gem and really was fascinated with the idea of encrypting the email so that bots crawling through the page would not recognize it as an email but the browser would. I was checking out the PHP code and thought that there had to be an easier way to write the function so that there were not so many lines of code and this is what I came up with.

function encryptString($str) {
    $size = strlen($str); // saves the string length into a variable
    $i=0;
    $ch = "";
    while ($i<$size) { // stumbles through the string changing characters to ordinals
        $ch.= "&#" . ord(substr($str, $i, 1)) . ";";
        $i++;
    }
    return $ch;
}


Generally, it can be used to encrypt any string from this:
[email protected]


into this:
email@server.com
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
Hayden

This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top