<?php

if(isset($_GET['mode'])) {

    
$mode=urlencode($_GET['mode']);
    
$val=$_GET['val'];

    switch(
$mode) {

        case 
"base64_encode": echo base64_encode($val); break;
        case 
"base64_decode": echo base64_decode($val); break;
        case 
"urldecode": echo urldecode($val); break;
        case 
"urlencode": echo urlencode($val); break;
        case 
"htmlentities": echo htmlentities($val); break;
        case 
"rot13": echo str_rot13($val);break;
        case 
"md5": echo md5($val);break;
        case 
"sha1": echo sha1($val);break;
        case 
"all":
            echo 
"base64_encode: ".base64_encode($val)."<br/>";
            echo 
"base64_decode: ".base64_decode($val);
            echo 
"<br/>";
            echo 
"urldecode: ".urldecode($val);
            echo 
"<br/>";
            echo 
"urlencode: ".urlencode($val)."<br/>";
            echo 
"htmlentities: ".htmlentities($val)."<br/>";
            echo 
"addslashes: ".addslashes($val)."<br/>";
            echo 
"rot13: ".str_rot13($val)."<br/>";
            echo 
"md5: ".md5($val)."<br/>";
            echo 
"sha1: ".sha1($val)."<br/>";
        break;
    }

exit(
0);

}

?>
<html><head>
<title>Transform or encrypt data to base64 encode decode, urlencode decode, addslashes and htmlentities - using PHP and AJAX</title>
<script>
    function transformit() {
            var xmlhttp=false;
            var url="/content/transform.php";
            var val=document.transform.elements["val"].value;
            var mode=document.transform.elements["thismode"].value;
            url+="?mode="+mode;
            url+="&val="+val;
                        /*@cc_on @*/
            /*@if (@_jscript_version >= 5)
            // JScript gives us Conditional compilation, we can cope with old IE versions.
            // and security blocked creation of the objects.
            try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
            try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
            xmlhttp = false;
            }
            }
            @end @*/

            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                                try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; }
                        }
            if (!xmlhttp && window.createRequest) {
                                try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; }
                        }
            subject_id = 'output_div';
            xmlhttp.open("GET",url, true);
            xmlhttp.onreadystatechange = function() {
                if(xmlhttp.readyState==4) { document.getElementById(subject_id).innerHTML = xmlhttp.responseText; }
            }
            xmlhttp.send(null);
    }
</script>
</head><body style="margin:0; padding:0;">
<table><tr><td valign=top>
<b>Enter data to transform and select your encode method</b>
<br/>
<script type="text/javascript"><!--
google_ad_client = "pub-6149817849643083";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728x15_0ads_al_s";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_link = "0000FF";
google_color_bg = "FFFFFF";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br/>
<form onsubmit="return false" name="transform">
<!--<input type="text" maxlength=65 size=65 name="val" id="val"></input> -->
<textarea name="val" id="val" cols=65 rows=8></textarea>

<select name="thismode" id="thismode" onchange="return transformit()">
<option>--- select from below ---</option>
<option value="base64_encode">base64_encode</option>
<option value="base64_decode">base64_decode</option>
<option value="urlencode">urlencode</option>
<option value="urldecode">urldecode</option>
<option value="htmlentities">htmlentities</option>
<option value="addslashes">addslashes</option>
<option value="rot13">rot13</option>
<option value="sha1">sha1</option>
<option value="md5">md5</option>
<option value="all">all</option>
</select>
</form>
<br/>
<div id='output_div'>Transform or encrypt data to base64 encode decode, urlencode decode, addslashes and htmlentities - using PHP and AJAX.<br/><br/>
<b>BTW</b> - also check out my <a target=_blank href="/content/idx.php?option=toascii">character to ASCII free online tool here.</a>
</div>
</td><td align=right>
<table border="0" cellspacing="0" cellpadding="0" width="180px">
<tr> <td>

</td> </tr> </table>
</td></tr></table>
</body></html>