Character-Hex Conversion
This converter is on my personal portal page for two reasons:
-
Encoded URLs are hard to read. As is hex-obfuscated text. The converter decodes them.
-
URLs occasionally need to be encoded or plain text obfuscated. The converter encodes them.
The converter is a stand-alone PHP script. Nothing needs to be customized. The script is designed so it can be displayed within an iframe or used by itself without modification.
The PHP converter may be installed on your server or used right here on this page. Paste the encoded text or the text to encode into the box. Then click the appropriate button to convert from hex to characters or characters to hex.
"Hex" means "hexadecimal," a numbering system with 16 characters – "0123456789abcdef". (Decimal has 10 characters – "0123456789". Binary has 2 characters – "01".)
When text is encoded with this converter, each character is represented by a percent character and two hexadecimal characters. As an example, the letter a is converted to the hexadecimal %61 and hexadecimal %61 is converted to the letter a. The encoded text is three times as long as the decoded text.
As an example of hex obfuscation, this is my name hex encoded:
%57%69%6c%6c%20%42%6f%6e%74%72%61%67%65%72
Here is a secret message:
%54%68%61%6e%6b%73%0d%0a%66%6f%72%0d%0a%76%69%73%69%74%69%6e%67%21
It is possible to encode encoded text. If decoding leaves "%" and two hex characters within the text, it may have been encoded two or more times. Decode it again.
Here is my first name and its encoding through two iterations:
Will
%57%69%6c%6c
%25%35%37%25%36%39%25%36%63%25%36%63
Put the last iteration into the converter and decode it twice to reveal "Will".
If you decide to use the convert tool at this page instead of installing on your server, bookmark this page now.
To install the converter on your server, copy the code in this box, paste it into a file named HEXize.php, and upload HEXize.php to your server.
<?php # September 23, 2013 # https://www.willmaster.com # Copyright 2013 Will Bontrager Software LLC $value = ''; if( count($_POST) ) { $value = stripslashes($_POST['TheText']); } if( isset($_POST['toHex']) ) { $string = ''; $length = strlen($value); for( $i = 0; $i < $length; $i++ ) { $ts = decHex( ord( substr($value, $i, 1) ) ); $string .= ( strlen($ts) < 2 ) ? "%0$ts" : "%$ts"; } $value = $string; } else { $value = rawurldecode($value); } ?><!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>Character-Hex Conversion</title> <style type="text/css"> body { margin:0; background-color:white; } .textbox { font-family:sans-serif; font-size:14px; background-color:white; border:1px solid black; border-radius:7px; padding:5px; width:289px; height:50px; } #content { width:300px; margin:0 auto 0 auto; } </style> </head> <body><div id="content"> <form style="margin:0;" method="post" enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']); ?>"> <textarea id="TheText" name="TheText" class="textbox" wrap="off"><?php echo($value); ?></textarea> <div style="float:left;"><input type="submit" name="fromHEC" value="Hex->Character" style="width:145px; margin:0;"></div> <div style="float:right;"><input type="submit" name="toHex" value="Character->Hex" style="width:145px; margin:0;"></div> <div style="clear:both;"></div> <div style="width:200px; margin:0 auto 0 auto;"> <div style="float:left;"><input type="button" value="Select" onclick="SelectContent()" style="width:95px;"></div> <div style="float:right;"><input type="button" value="Clear" onclick="ClearContent()" style="width:95px;"></div> <div style="clear:both;"></div> </div> </form> <script type="text/javascript"> var id = document.getElementById("TheText"); function SelectContent() { id.select(); } function ClearContent() { id.value=""; } </script> <p style="margin:0; font-size:12px; text-align:center;">Copyright 2013 <a href="//www.willmaster.com/">Will Bontrager Software LLC</a></p> </div> </body> </html>
To use your installation, type the URL of HEXize.php into your browser's address bar.
To use HEXize.php within an iframe, here is the iframe code:
<iframe src="URL/TO/SCRIPT" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" width="320" height="133"> </iframe>
Replace URL/TO/SCRIPT with the URL of HEXize.php on your server. Paste the code into your web page where the hex-character converter shall be published.
URLs and hex-obfuscated text can now be decoded. And they can be encoded.
Will Bontrager